Exemplo n.º 1
0
def autocomplete(command: str):
    """ """

    # On Linux/OSX the completer delims are retrieved from the readline module,
    # but the delims are different on Windows. So for testing consistency we
    # supply the Linux/OSX delims explicitly here in place of:
    # readline.get_completer_delims()

    completer_delims = ' \t\n`~!@#$%^&*()-=+[{]}\\|;:\'",<>/?'

    with patch('readline.get_line_buffer', return_value=command):
        cs = CauldronShell()
        line = command.lstrip()

        splits = re.split('[{}]{{1}}'.format(
            re.escape(completer_delims)),
            line
        )

        return cs.completedefault(
            text=splits[-1],
            line=line,
            begin_index=len(line) - len(splits[-1]),
            end_index=len(line) - 1
        )
Exemplo n.º 2
0
def run_command(command: str) -> 'environ.Response':
    """

    :param command:
    :return:
    """

    cs = CauldronShell()
    cs.default(command)
    return cs.last_response
Exemplo n.º 3
0
def run_shell(args: dict) -> int:
    """Run the shell sub command"""

    if args.get('project_directory'):
        return run_batch(args)

    shell = CauldronShell()

    if in_project_directory():
        shell.cmdqueue.append('open "{}"'.format(os.path.realpath(os.curdir)))

    shell.cmdloop()
    return 0
Exemplo n.º 4
0
def run_shell(args: dict) -> int:
    """Run the shell sub command"""

    if args.get('project_directory'):
        return run_batch(args)

    shell = CauldronShell()

    if in_project_directory():
        shell.cmdqueue.append('open "{}"'.format(os.path.realpath(os.curdir)))

    shell.cmdloop()
    return 0
Exemplo n.º 5
0
def run():
    try:
        import cauldron
    except ImportError:
        sys.path.append(os.path.abspath(os.path.join(MY_DIRECTORY, '..',
                                                     '..')))

        try:
            import cauldron
        except ImportError:
            raise ImportError(' '.join(
                ('Unable to import cauldron.'
                 'The package was not installed in a known location.')))

    from cauldron.cli.shell import CauldronShell
    from cauldron import environ
    from cauldron.cli import batcher

    args = parse_args()

    if args.version:
        print('VERSION: {}'.format(environ.package_settings().get(
            'version', 'unknown')))
        sys.exit(0)

    if args.project_directory:
        batcher.run_project(project_directory=args.project_directory,
                            log_path=args.logging_path,
                            output_directory=args.output_directory,
                            shared_data=load_shared_data(
                                args.shared_data_path))
        sys.exit(0)

    CauldronShell().cmdloop()
Exemplo n.º 6
0
def run_shell():
    """ Starts the cauldron shell environment for console based interaction """
    from cauldron.cli.shell import CauldronShell
    CauldronShell().cmdloop()