Esempio n. 1
0
def main():
    """
Usage: with (--version | [--] <command> ...)

Arguments:
    command     The command to use as prefix to your context.

Options:
    -h --help   Show this screen.
    --version   Show the current version.
    """
    arguments = docopt(main.__doc__)

    if arguments.get('--version'):
        print('with {}'.format(withtool.__version__))
        sys.exit()

    command = parse_command(arguments['<command>'])

    prompt = " ".join(command)

    while True:
        call = list(command)
        sub = yield from get_prompt(prompt)
        if sub:
            call.append(sub)
        run(call)
Esempio n. 2
0
def main():
    """
Usage: with (--version | <command>)

Arguments:
    command     The command to use as prefix to your context.

Options:
    -h --help   Show this screen.
    --version   Show the current version.
    """
    arguments = docopt(main.__doc__)

    if arguments.get('--version'):
        print('with {}'.format(withtool.__version__))
        sys.exit()

    while True:
        sub = yield from get_prompt(arguments['<command>'])
        call = '{cmd} {sub}'.format(cmd=arguments['<command>'], sub=sub)
        run(call)
Esempio n. 3
0
    def it_calls_an_async_prompt(self):
        with mock.patch('withtool.prompt.prompt_async') as mock_prompt_async:
            yield from prompt.get_prompt('cmd')

        assert mock_prompt_async.called
Esempio n. 4
0
    def it_exits_on_EOF_error(self):
        with mock.patch('withtool.prompt.prompt_async') as mock_prompt_async:
            mock_prompt_async.side_effect = EOFError

            with pytest.raises(SystemExit):
                yield from prompt.get_prompt('cmd')
Esempio n. 5
0
 def it_returns_a_generator(self):
     result = prompt.get_prompt('cmd')
     assert isinstance(result, types.GeneratorType)