Skip to content

Add clear internal command to clear screen #61

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
@@ -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):
@@ -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