Exemple #1
0
    def sandbox():

        # `exit` is defined only when in the `sandbox` REPL.
        @appliance.command(help=exit_sandbox_help)
        def exit():
            raise ExitSandboxException()

        @appliance.group(help='Toggle advanced mode')
        def advanced():
            pass

        @advanced.command(help='Enable advanced mode')
        def enable():
            toggle_advanced_mode(True)

        @advanced.command(help='Disable advanced mode')
        def disable():
            toggle_advanced_mode(False)

        try:
            repl(
                click.get_current_context(),
                prompt_kwargs=_prompt_kwargs(),
                allow_system_commands=False,
                allow_internal_commands=False,
            )
        except ExitSandboxException:
            return
Exemple #2
0
def repl(ctx):
    """
    Enter interactive mode (default).

    Enter the interactive mode where pywbemcli commands can be entered
    interactively. The prompt is changed to 'pywbemcli>'.

    Command history is supported. The command history is stored in a file
    ~/.pywbemcli_history.

    Pywbemcli may be terminated from this mode by entering
    <CTRL-D>, :q, :quit, :exit
    """

    history_file = PYWBEMCLI_HISTORY_FILE
    if history_file.startswith('~'):
        history_file = os.path.expanduser(history_file)

    click.echo("Enter 'help' for help, <CTRL-D> or ':q' to exit pywbemcli.")

    prompt_kwargs = {
        'message': PYWBEMCLI_PROMPT,
        'history': FileHistory(history_file),
    }

    if USE_AUTOSUGGEST:
        prompt_kwargs['auto_suggest'] = AutoSuggestFromHistory()

    click_repl.repl(ctx, prompt_kwargs=prompt_kwargs)
Exemple #3
0
def repl(ctx):
    obj = ctx.ensure_object(dict)
    obj['in_repl'] = True
    click.echo('Anaconda Enterprise 5 REPL')
    click.echo('Type "--help" for a list of commands.')
    click.echo('Type "<command> --help" for help on a specific command.')
    click_repl.repl(ctx, prompt_kwargs={'history': FileHistory(os.path.expanduser('~/.ae5/history'))})
Exemple #4
0
def cli(log_level, config_file=None):
    logging.getLogger().setLevel(log_level)

    if config_file:
        config.read(config_file)

    config_dir = os.path.join(click.get_app_dir(__app_name__))

    log.debug('Creating application directory "{}"'.format(config_dir))

    try:
        os.makedirs(config_dir)
    except OSError as exc:
        if exc.errno == errno.EEXIST and os.path.isdir(config_dir):
            pass
        else:
            log.critical(
                'Cannot create application directory "{}"'.format(config_dir))
            sys.exit(1)

    click.clear()
    click.secho(__banner__, bold=True)

    ctx = click.get_current_context()

    if ctx.invoked_subcommand is None:
        prompt_kwargs = {
            'history':
            FileHistory(
                os.path.join(click.get_app_dir(__app_name__), 'history')),
            'message':
            'Presence> ',
        }
        repl(ctx, prompt_kwargs=prompt_kwargs)
Exemple #5
0
def shell():
    prompt_kwargs = {
        'history': FileHistory('/tmp/.hfos-manage.history'),
    }
    print("""HFOS - Management Tool Interactive Prompt

Type -h for help, tab completion is available, hit Ctrl-D to quit.""")
    repl(click.get_current_context(), prompt_kwargs=prompt_kwargs)
Exemple #6
0
def shell():
    """
    Open an interactive tools, just like a shell.
    """
    prompt_kwargs = {
        'history':
        FileHistory(str(Path(WIZNOTE_HOME).joinpath(".wizcli_history"))),
        'message': u"wizcli>>> "
    }
    repl(click.get_current_context(), prompt_kwargs=prompt_kwargs)
Exemple #7
0
def repl(ctx):
    stash_defaults()
    click.echo('Anaconda Enterprise 5 REPL')
    click.echo('Type "--help" for a list of commands.')
    click.echo('Type "<command> --help" for help on a specific command.')
    click_repl.repl(ctx,
                    prompt_kwargs={
                        'history':
                        FileHistory(os.path.expanduser('~/.ae5/history'))
                    })
Exemple #8
0
def command_repl():
    """Start mate in a read-eval-print-loop (REPL) interactive shell."""
    print("mate v{}".format(get_version()))
    prompt_kwargs = {
        "message": u"mate> ",
        "history": FileHistory(HISTORY_FILE),
    }
    try:
        repl(click.get_current_context(), prompt_kwargs=prompt_kwargs)
    except ExitReplException:
        exit()
Exemple #9
0
def ui():
    click.echo("""Welcome to the Tutor interactive shell UI!
Type "help" to view all available commands.
Type "local quickstart" to configure and launch a new platform from scratch.
Type <ctrl-d> to exit.""")
    while True:
        try:
            click_repl.repl(click.get_current_context())
            return  # this happens on a ctrl+d
        except Exception:
            pass
Exemple #10
0
def shell():
    """
    Starts a interactive cogctl session.

    Command history is stored at $HOME/.cogctl_history

    NOTE: Command bundle execution is NOT supported.
    """
    prompt_kwargs = {
        'history': FileHistory(os.path.expandvars("$HOME/.cogctl_history"))
    }
    click_repl.repl(click.get_current_context(), prompt_kwargs=prompt_kwargs)
Exemple #11
0
def repl():
    '''Start interactive entry dialog mock'''
    data_directory = appdirs.user_data_dir('INCode', 'rknuus')
    if not os.path.isdir(data_directory):
        try:
            os.makedirs(data_directory)
        except OSError:
            print("Creation of the directory %s failed" % data_directory)
            return
    prompt_kwargs = {
        'history': FileHistory('{}/.edmc_history.txt'.format(data_directory))
    }
    click_repl.repl(click.get_current_context(), prompt_kwargs=prompt_kwargs)
Exemple #12
0
def main():
    '''
    Start an interactive shell. All commands and subcommands are available
    in it.

    If stdin is not a TTY, no prompt will be printed, but only commands read
    from stdin.
    '''

    prompt_kwargs = {
        'history': FileHistory(os.path.expanduser('~/.termicoder-history')),
    }
    repl(click.get_current_context(), prompt_kwargs=prompt_kwargs)
Exemple #13
0
def ocli_repl(ctx, repo: Repo, fullscreen):
    """ start interactive console"""
    repo.is_repl = True
    output.comment("""        
        use  ? command to OCLI help
        use :? command to show console help
        use <TAB> to auto-complete commands
        use :q or Ctrl-d to exit       
        """)
    if fullscreen:
        prompt_kwargs['bottom_toolbar'] = bottom_toolbar
    prompt_kwargs['message'] = prompt_message_callback(repo)
    repl(ctx, prompt_kwargs=prompt_kwargs)
Exemple #14
0
def shell(ctx):
    """Open an shell to work with the manage tool interactively."""

    ctx.obj['interactive'] = True

    print("""Isomer - Management Tool Interactive Prompt

    Type -h for help, tab completion is available, hit Ctrl-D to quit.""")

    style = Style.from_dict({
        # User input (default text).
        "": "ansiwhite",
        "space": "ansigreen nounderline",
        "prompt": "ansicyan underline",
        "bottom-toolbar": "ansiblue",
        "bottom-toolbar-name": "bg:ansicyan",
    })

    completer_styles = {
        "command": "ansicyan",
        "option": "ansigreen",
        "argument": "ansiyellow",
    }

    message = [("class:prompt", ">>"), ("class:space", " ")]

    def bottom_toolbar():
        """Returns a nice isomeric toolbar with the current version displayed"""
        return [
            ("class:bottom-toolbar-name", " Isomer "),
            ("class:bottom-toolbar", "maintenance tool (%s)" % version_info),
        ]

    prompt_kwargs = {
        "history": FileHistory("/tmp/.isomer-manage.history"),
        "message": message,
        "style": style,
        "bottom_toolbar": bottom_toolbar,
    }

    repl(
        click.get_current_context(),
        prompt_kwargs=prompt_kwargs,
        styles=completer_styles,
    )
Exemple #15
0
def calmrepl():
    """Enable an interactive prompt shell

    > :help

    REPL help:

    External Commands:

      prefix external commands with "!"

    Internal Commands:

      prefix internal commands with ":"

      :exit, :q, :quit  exits the repl

      :?, :h, :help     displays general help information"""
    repl(click.get_current_context())
Exemple #16
0
    def sandbox():

        # `exit` is defined only when in the `sandbox` REPL.
        @appliance.command(help=exit_sandbox_help)
        def exit():
            raise ExitSandboxException()

        @appliance.command(help=exit_sandbox_help)
        def quit():
            raise ExitSandboxException()

        try:
            repl(
                click.get_current_context(),
                prompt_kwargs=_prompt_kwargs(),
                allow_system_commands=False,
                allow_internal_commands=False,
            )
        except ExitSandboxException:
            return
Exemple #17
0
def repl(ctx):
    """
    Enter interactive (REPL) mode (default).

    Parameters:

      ctx (:class:`click.Context`): The click context object. Created by the
        ``@click.pass_context`` decorator.
    """

    history_file = REPL_HISTORY_FILE
    if history_file.startswith('~'):
        history_file = os.path.expanduser(history_file)

    print("Enter 'help' for help, <CTRL-D> or ':q' to exit.")

    prompt_kwargs = {
        'message': REPL_PROMPT,
        'history': FileHistory(history_file),
    }
    click_repl.repl(ctx, prompt_kwargs=prompt_kwargs)
Exemple #18
0
        def repl_callback(ctx, param, value):
            if not value or ctx.resilient_parsing:
                return

            prompt_kwargs = {
                'completer':
                KickoffCompleter(ctx.command, compl_blacklist),
                # simple text can be provided here if colors are not desired
                'message': [('class:appname', self._prompt_caption),
                            ('class:suffix', self._prompt_suffix)],
                'style':
                Style.from_dict({
                    'appname': 'ansicyan bold',
                    'suffix': 'ansigray'
                }),
                'enable_system_prompt':
                True,
                'enable_open_in_editor':
                True,  # CTRL+X CTRL+E
                'complete_while_typing':
                True,
                'auto_suggest':
                AutoSuggestFromHistory(),

                # this works by default, if enabled explicitely complete_while_typing becomes disabled
                #'enable_history_search': True, # CTRL+R
            }

            if self._config.enable_history:
                prompt_kwargs['history'] = FileHistory(
                    Path('~').expanduser() / f'.{self._prog_name}_history')

            click_repl.repl(ctx,
                            prompt_kwargs=prompt_kwargs,
                            allow_system_commands=True,
                            allow_internal_commands=False)
            ctx.exit()
Exemple #19
0
def repl():
    """Start an interactive session"""
    prompt_kwargs = {
        'history': FileHistory(os.path.expanduser('~/.repl_history'))
    }
    click_repl.repl(click.get_current_context(), prompt_kwargs=prompt_kwargs)
Exemple #20
0
def console():
    """Start an interactive console session"""
    repl(click.get_current_context())
Exemple #21
0
def interactive():
    "run in interactive mode"
    click.echo("Running in interactive mode. This supports tab completion.")
    click.echo("Use ':help' for help info, or ':quit' to quit.")
    repl(click.get_current_context())
Exemple #22
0
def ui():
    click.echo("""Welcome to the Tutor interactive shell UI!
Type "help" to view all available commands.
Type "local quickstart" to configure and launch a new platform from scratch.
""")
    click_repl.repl(click.get_current_context())
Exemple #23
0
def repl():
    click_repl.repl(click.get_current_context())
Exemple #24
0
def calmrepl():
    """Enable an interactive prompt shell"""
    repl(click.get_current_context())
Exemple #25
0
def main(ctx):
    if ctx.invoked_subcommand is None:
        repl(ctx,
             allow_system_commands=False,
             prompt_kwargs={'completer': None})
Exemple #26
0
def cli():
    """This script showcases different terminal UI helpers in Click."""
    prompt_kwargs = {
        'history': FileHistory('./hsitory.txt'),
    }
    repl(click.get_current_context(), prompt_kwargs=prompt_kwargs)
Exemple #27
0
def cli(ctx):
    """
    The Click Command group definition
    """
    if ctx.invoked_subcommand is None:
        repl(ctx, prompt_kwargs={'message':u'-->> '})
Exemple #28
0
def repl(ctx):
    """Start the REPL"""
    click_repl.repl(ctx,
                    prompt_kwargs=ctx.obj.prompt_kwargs,
                    allow_system_commands=False,
                    allow_internal_commands=False)