Esempio n. 1
0
    def test_invoke_no_args(self):
        shell = Shell()

        ctx = shell.make_context('click-shell-test', args=[])

        with pytest.raises(IOError):
            shell.invoke(ctx)
Esempio n. 2
0
    def test_invoke_no_args(self):
        shell = Shell()

        ctx = shell.make_context('click-shell-test', args=[])

        with pytest.raises(IOError):
            shell.invoke(ctx)
Esempio n. 3
0
    def test_invoke_with_args(self):
        shell = Shell()

        # Create a 'foo' command
        @shell.command()
        def foo():
            click.echo('bar')
            return 0

        ctx = shell.make_context('click-shell-test', args=['foo'])

        retcode = shell.invoke(ctx)

        assert retcode == 0
Esempio n. 4
0
    def test_invoke_with_args(self):
        shell = Shell()

        # Create a 'foo' command
        @shell.command()
        def foo():
            click.echo('bar')
            return 0

        ctx = shell.make_context('click-shell-test', args=['foo'])

        retcode = shell.invoke(ctx)

        assert retcode == 0
Esempio n. 5
0
def jumbo(ctx, cluster):
    """
    Execute a Jumbo command.
    If no command is passed, start the Jumbo shell interactive mode.
    """

    # Create the shell
    sh = Shell(prompt=click.style('jumbo > ', fg='green') if OS != 'Windows'
               else 'jumbo > ',
               intro=printlogo.jumbo_ascii() +
               '\nJumbo Shell. Enter "help" for list of supported commands.' +
               ' Type "quit" to leave the Jumbo Shell.' +
               click.style('\nJumbo v0.4.4',
                           fg='cyan'))
    # Save the shell in the click context (to modify its prompt later on)
    ctx.meta['jumbo_shell'] = sh.shell
    # Register commands that can be used in the shell
    sh.add_command(create)
    sh.add_command(exit)
    sh.add_command(delete)
    sh.add_command(use)
    sh.add_command(addnode)
    sh.add_command(rmnode)
    sh.add_command(editnode)
    sh.add_command(listclusters)
    sh.add_command(listnodes)
    sh.add_command(repair)
    sh.add_command(addservice)
    sh.add_command(addcomponent)
    sh.add_command(listcomponents)
    sh.add_command(rmservice)
    sh.add_command(rmcomponent)
    sh.add_command(checkservice)
    sh.add_command(listservices)
    sh.add_command(start)
    sh.add_command(stop)
    sh.add_command(status)
    sh.add_command(provision)
    sh.add_command(restart)

    # If cluster exists, call manage command (saves the shell in session
    #  variable svars and adapts the shell prompt)
    if cluster:
        if not checks.check_cluster(cluster):
            click.echo('This cluster does not exist.'
                       ' Use "create NAME" to create it.', err=True)
        else:
            ctx.invoke(use, name=cluster)

    # Run the command, or the shell if no command is passed
    sh.invoke(ctx)
Esempio n. 6
0
    def test_create(self):

        shell = Shell()

        assert isinstance(shell, click.MultiCommand)