def add_cstar_arguments()

in cstar/args.py [0:0]


def add_cstar_arguments(parser, commands, execute_command, execute_continue, execute_cleanup):
    """Argument parsing for case when cstar is called specifying a command to run"""
    subparsers = parser.add_subparsers(dest='sub_command')

    continue_parser = subparsers.add_parser('continue', help='Continue a previously created job (*)')
    continue_parser.set_defaults(func=execute_continue)
    continue_parser.add_argument('job_id')
    continue_parser.add_argument('--retry-failed', action="store_true", default=False,
                        help='Retry failed nodes.')
    _add_common_arguments(continue_parser)
    _add_cstar_arguments_without_command(continue_parser)
    _add_ssh_arguments(continue_parser)
    _add_jmx_auth_arguments(continue_parser)

    cleanup_parser = subparsers.add_parser('cleanup-jobs', help='Cleanup old finished jobs and exit (*)')
    cleanup_parser.set_defaults(func=execute_cleanup)
    _add_common_arguments(cleanup_parser)
    _add_cstar_arguments_without_command(cleanup_parser)
    _add_ssh_arguments(cleanup_parser)
    _add_jmx_auth_arguments(cleanup_parser)

    for (name, command) in commands.items():
        command_parser = subparsers.add_parser(name, help=command.description)
        for arg in command.arguments:
            command_parser.add_argument(arg.option, dest=arg.name, help=arg.description, required=arg.required, default=arg.default)
        _add_destination_arguments(command_parser)
        _add_strategy_arguments(command_parser)
        _add_common_arguments(command_parser)
        _add_ssh_arguments(command_parser)
        _add_jmx_auth_arguments(command_parser)
        command_parser.set_defaults(func=lambda args: execute_command(args), command=command)