Esempio n. 1
0
def test_no_matching_cmd(args):
    commands = [
        cmds.Command(hierarchy=['cmd-c'],
                     arg_keys=['arg-0', 'arg-1', 'arg-2'],
                     function=pytest.fail),
    ]

    with pytest.raises(Exception):
        cmds.execute(commands, args)
Esempio n. 2
0
def test_no_matching_cmd(args):
    commands = [
        cmds.Command(
            hierarchy=['cmd-c'],
            arg_keys=['arg-0', 'arg-1', 'arg-2'],
            function=pytest.fail),
    ]

    with pytest.raises(Exception):
        cmds.execute(commands, args)
Esempio n. 3
0
def _main(argv):
    args = docopt.docopt(default_doc("service"),
                         argv=argv,
                         version="dcos-service version {}".format(
                             dcoscli.version))

    return cmds.execute(_cmds(), args)
Esempio n. 4
0
def main():
    signal.signal(signal.SIGINT, signal_handler)
    args = docopt.docopt(__doc__,
                         version='dcos-marathon version {}'.format(
                             constants.version))

    return cmds.execute(_cmds(), args)
Esempio n. 5
0
def _main(argv):
    args = docopt.docopt(
        default_doc("service"),
        argv=argv,
        version="dcos-service version {}".format(dcoscli.version))

    return cmds.execute(_cmds(), args)
Esempio n. 6
0
def _main(argv):
    """The main function for the 'task' subcommand"""

    # We must special case the 'dcos task exec' subcommand in order to
    # allow us to pass arguments to docopt in a more user-friendly
    # manner. Specifically, we need to be able to to pass arguments
    # beginning with "-" to the command we are trying to launch with
    # 'exec' without docopt trying to match them to a named parameter
    # for the 'dcos' command itself.
    if len(argv) > 1 and argv[1] == "exec":
        args = docopt_wrapper(
            default_doc("task_exec"),
            default_doc("task"),
            argv=argv[2:],
            version="dcos-task version {}".format(dcoscli.version),
            options_first=True,
            base_subcommand="task",
            subcommand="exec")
    else:
        args = docopt.docopt(
            default_doc("task"),
            argv=argv,
            version="dcos-task version {}".format(dcoscli.version))

    return cmds.execute(_cmds(), args)
Esempio n. 7
0
def _main(argv):
    args = docopt.docopt(default_doc("experimental"),
                         argv=argv,
                         version='dcos-experimental version {}'.format(
                             dcoscli.version))
    http.silence_requests_warnings()
    return cmds.execute(_cmds(), args)
Esempio n. 8
0
def _main(argv):
    """The main function for the 'task' subcommand"""

    # We must special case the 'dcos task exec' subcommand in order to
    # allow us to pass arguments to docopt in a more user-friendly
    # manner. Specifically, we need to be able to to pass arguments
    # beginning with "-" to the command we are trying to launch with
    # 'exec' without docopt trying to match them to a named parameter
    # for the 'dcos' command itself.
    if len(argv) > 1 and argv[1] == "exec":
        args = docopt_wrapper(
            default_doc("task_exec"),
            default_doc("task"),
            argv=argv[2:],
            version="dcos-task version {}".format(dcoscli.version),
            options_first=True,
            base_subcommand="task",
            subcommand="exec")
    else:
        args = docopt.docopt(
            default_doc("task"),
            argv=argv,
            version="dcos-task version {}".format(dcoscli.version))

    return cmds.execute(_cmds(), args)
Esempio n. 9
0
def _main(argv):
    args = docopt.docopt(
        default_doc("marathon"),
        argv=argv,
        version='dcos-marathon version {}'.format(dcoscli.version))

    return cmds.execute(_cmds(), args)
Esempio n. 10
0
def _main(argv):
    args = docopt.docopt(
        default_doc("experimental"),
        argv=argv,
        version='dcos-experimental version {}'.format(dcoscli.version))
    http.silence_requests_warnings()
    return cmds.execute(_cmds(), args)
Esempio n. 11
0
def main():
    signal.signal(signal.SIGINT, signal_handler)
    args = docopt.docopt(
        __doc__,
        version='dcos-marathon version {}'.format(constants.version))

    return cmds.execute(_cmds(), args)
Esempio n. 12
0
def _main():
    util.configure_process_from_environ()

    args = docopt.docopt(
        _doc(),
        version="dcos-service version {}".format(dcoscli.version))

    return cmds.execute(_cmds(), args)
Esempio n. 13
0
def _main():
    util.configure_logger_from_environ()

    args = docopt.docopt(
        __doc__,
        version="dcos-task version {}".format(dcoscli.version))

    return cmds.execute(_cmds(), args)
Esempio n. 14
0
def _main():
    util.configure_process_from_environ()

    args = docopt.docopt(
        __doc__,
        version='dcos-help version {}'.format(dcoscli.version))

    return cmds.execute(_cmds(), args)
Esempio n. 15
0
def _main():
    util.configure_process_from_environ()

    args = docopt.docopt(_doc(),
                         version='dcos-help version {}'.format(
                             dcoscli.version))

    return cmds.execute(_cmds(), args)
Esempio n. 16
0
def test_single_cmd(args):
    commands = [
        cmds.Command(hierarchy=['cmd-a', 'cmd-b'],
                     arg_keys=['arg-0', 'arg-1', 'arg-2'],
                     function=function),
    ]

    assert cmds.execute(commands, args) == 1
Esempio n. 17
0
def _main():
    util.configure_process_from_environ()

    args = docopt.docopt(
        __doc__,
        version="dcos-node version {}".format(dcoscli.version))

    return cmds.execute(_cmds(), args)
Esempio n. 18
0
def _main():
    util.configure_process_from_environ()

    args = docopt.docopt(_doc(),
                         version='dcos-package version {}'.format(
                             dcoscli.version))
    http.silence_requests_warnings()

    return cmds.execute(_cmds(), args)
Esempio n. 19
0
def test_single_cmd(args):
    commands = [
        cmds.Command(
            hierarchy=['cmd-a', 'cmd-b'],
            arg_keys=['arg-0', 'arg-1', 'arg-2'],
            function=function),
    ]

    assert cmds.execute(commands, args) == 1
Esempio n. 20
0
def _main():
    util.configure_process_from_environ()

    args = docopt.docopt(
        _doc(),
        version='dcos-package version {}'.format(dcoscli.version))
    http.silence_requests_warnings()

    return cmds.execute(_cmds(), args)
Esempio n. 21
0
def test_missing_arg(args):
    commands = [
        cmds.Command(hierarchy=['cmd-a'],
                     arg_keys=['arg-3'],
                     function=pytest.fail),
    ]

    with pytest.raises(KeyError):
        returncode, err = cmds.execute(commands, args)
Esempio n. 22
0
def test_missing_arg(args):
    commands = [
        cmds.Command(
            hierarchy=['cmd-a'],
            arg_keys=['arg-3'],
            function=pytest.fail),
    ]

    with pytest.raises(KeyError):
        returncode, err = cmds.execute(commands, args)
Esempio n. 23
0
def _main():
    util.configure_logger_from_environ()

    args = docopt.docopt(
        __doc__,
        version='myriad cli version {}'.format(constants.version))

    http.silence_requests_warnings()

    return cmds.execute(_cmds(), args)
Esempio n. 24
0
def _main():
    util.configure_process_from_environ()

    args = docopt.docopt(__doc__,
                         version='dcos-management version {}'.format(
                             constants.version))

    http.silence_requests_warnings()

    return cmds.execute(_cmds(), args)
Esempio n. 25
0
def main():
    signal.signal(signal.SIGINT, signal_handler)
    args = docopt.docopt(__doc__, version=constants.version)

    try:
        ret = cmds.execute(_cmds(), args)
    except DCOSException as e:
        emitter.publish(e)
        ret = 1
    return ret
Esempio n. 26
0
def _main():
    util.configure_logger_from_environ()

    args = docopt.docopt(__doc__,
                         version='myriad cli version {}'.format(
                             constants.version))

    http.silence_requests_warnings()

    return cmds.execute(_cmds(), args)
Esempio n. 27
0
def test_similar_cmds(args):
    commands = [
        cmds.Command(hierarchy=['cmd-a', 'cmd-b'],
                     arg_keys=['arg-0', 'arg-1', 'arg-2'],
                     function=function),
        cmds.Command(hierarchy=['cmd-a'],
                     arg_keys=['arg-0', 'arg-1', 'arg-2'],
                     function=pytest.fail),
    ]

    assert cmds.execute(commands, args) == 1
Esempio n. 28
0
def main():
    signal.signal(signal.SIGINT, signal_handler)
    args = docopt.docopt(
        __doc__,
        version=constants.version)

    try:
        ret = cmds.execute(_cmds(), args)
    except DCOSException as e:
        emitter.publish(e)
        ret = 1
    return ret
Esempio n. 29
0
def test_similar_cmds(args):
    commands = [
        cmds.Command(
            hierarchy=['cmd-a', 'cmd-b'],
            arg_keys=['arg-0', 'arg-1', 'arg-2'],
            function=function),
        cmds.Command(
            hierarchy=['cmd-a'],
            arg_keys=['arg-0', 'arg-1', 'arg-2'],
            function=pytest.fail),
    ]

    assert cmds.execute(commands, args) == 1
Esempio n. 30
0
def _main(argv):
    args = docopt.docopt(default_doc("node"),
                         argv=argv,
                         version="dcos-node version {}".format(
                             dcoscli.version))

    if args.get('--master'):
        raise DCOSException(
            '--master has been deprecated. Please use --leader.')
    elif args.get('--slave'):
        raise DCOSException(
            '--slave has been deprecated. Please use --mesos-id.')

    return cmds.execute(_cmds(), args)
Esempio n. 31
0
def _main(argv):

    for i, arg in enumerate(argv):
        if arg == '--show-failures':
            argv[i] = '--failures'
            warning = ("'--show-failures' is deprecated, "
                       "please use '--failures' instead.\n")
            emitter.publish(DefaultError(warning))

    args = docopt.docopt(default_doc("job"),
                         argv=argv,
                         version='dcos-job version {}'.format(dcoscli.version))

    return cmds.execute(_cmds(), args)
Esempio n. 32
0
def _main(argv):
    args = docopt.docopt(
        default_doc("node"),
        argv=argv,
        version="dcos-node version {}".format(dcoscli.version))

    if args.get('--master'):
        raise DCOSException(
            '--master has been deprecated. Please use --leader.'
        )
    elif args.get('--slave'):
        raise DCOSException(
            '--slave has been deprecated. Please use --mesos-id.'
        )

    return cmds.execute(_cmds(), args)
Esempio n. 33
0
def _main():
    util.configure_process_from_environ()

    args = docopt.docopt(
        _doc(),
        version="dcos-node version {}".format(dcoscli.version))

    if args.get('--master'):
        raise DCOSException(
            '--master has been deprecated. Please use --leader.'
        )
    elif args.get('--slave'):
        raise DCOSException(
            '--slave has been deprecated. Please use --mesos-id.'
        )

    return cmds.execute(_cmds(), args)
Esempio n. 34
0
def _main(argv):
    doc_name = 'cluster'

    # If a cluster is attached and the cluster linker API is reachable,
    # use cluster_ee.txt.
    dcos_url = config.get_config_val('core.dcos_url')
    if dcos_url:
        try:
            cluster.get_cluster_links(dcos_url)
            doc_name = 'cluster_ee'
        except Exception:
            pass

    args = docopt.docopt(
        default_doc(doc_name),
        argv=argv,
        version='dcos-cluster version {}'.format(dcoscli.version))

    http.silence_requests_warnings()

    return cmds.execute(_cmds(doc_name), args)