Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion click_repl/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from collections import defaultdict
from prompt_toolkit.completion import Completer, Completion
from prompt_toolkit.history import InMemoryHistory
from prompt_toolkit.shortcuts import prompt
from prompt_toolkit.shortcuts import prompt, clear
import click
import click._bashcomplete
import click.parser
Expand Down Expand Up @@ -76,10 +76,15 @@ def _help_internal():
return formatter.getvalue()


def _clear_internal():
return clear


_register_internal_command(["q", "quit", "exit"], _exit_internal, "exits the repl")
_register_internal_command(
["?", "h", "help"], _help_internal, "displays general help information"
)
_register_internal_command(["c", "cls", "clear"], _clear_internal, "clears screen")


class ClickCompleter(Completer):
Expand Down Expand Up @@ -234,6 +239,9 @@ def get_command():
if isinstance(result, six.string_types):
click.echo(result)
continue
if callable(result):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this branch needed? Just call clear from within clear_internal?

result()
continue
except ExitReplException:
break

Expand Down