How to use the aioconsole.AsynchronousCli function in aioconsole

To help you get started, we’ve selected a few aioconsole examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github vxgmichel / aioconsole / tests / test_command.py View on Github external
def make_cli(streams=None):

    @asyncio.coroutine
    def say_hello(reader, writer, name=None):
        data = "Hello {}!".format(name) if name else "Hello!"
        writer.write(data.encode() + b'\n')

    parser = argparse.ArgumentParser(description="Say hello")
    parser.add_argument('--name', '-n', type=str)
    commands = {'hello': (say_hello, parser)}
    return AsynchronousCli(commands, streams, prog='hello')
github vxgmichel / aioconsole / example / cli.py View on Github external
def make_cli(streams=None):
    parser = argparse.ArgumentParser(description="Display the message history")
    parser.add_argument('--pattern', '-p', type=str,
                        help='pattern to filter hostnames')
    commands = {'history': (get_history, parser)}
    return AsynchronousCli(commands, streams, prog='echo')