Add command arguments
53
def add_arguments(self, parser):
        """"""
        parser.add_argument(self._source_param, **self._source_kwargs)
        parser.add_argument('--base', '-b', action='store',
            help=   'Supply the base currency as code or a settings variable name. '
                    'The default is taken from settings CURRENCIES_BASE or SHOP_DEFAULT_CURRENCY, '
                    'or the db, otherwise USD')
1250315
def add_func(self, callback, names, *args):
        

        if isinstance(names, list):
            for name in names:
                self.add_func(callback, name, *args)
                self.aliases[name] = names
        elif isinstance(names, str):
            if names in self.cmds or names in self.clis:
                raise ValueError('Attempting to overwrite cmd or extern CLI: %s' % names)
            parser = argparse.ArgumentParser(prog=names)
            for cmd, spec in args:
                parser.add_argument(cmd, **spec)
            self.cmds[names] = (callback, parser)
        else:
            raise TypeError("Command must be specified by str name or list of names")
1142524
def add_shell_action(sub_parser: ArgumentParser) -> ArgumentParser:
    """"""

    sub_parser.add_argument(
        '-p', '--project',
        dest='project_directory',
        type=str,
        default=None
    )

    sub_parser.add_argument(
        '-l', '--log',
        dest='logging_path',
        type=str,
        default=None
    )

    sub_parser.add_argument(
        '-o', '--output',
        dest='output_directory',
        type=str,
        default=None
    )

    sub_parser.add_argument(
        '-s', '--shared',
        dest='shared_data_path',
        type=str,
        default=None
    )

    return sub_parser
87228
def add_command_line_options_argparse(cls, argparser):
        """"""
        import argparse

        class SetParameter(argparse.Action):
            """callback object for ArgumentParser"""

            def __call__(self, parser, namespace, value, option_string=None):
                cls.config[option_string] = value
                if option_string == "--stomp-conf":
                    cls.load_configuration_file(value)

        argparser.add_argument(
            "--stomp-host",
            metavar="HOST",
            default=cls.defaults.get("--stomp-host"),
            help="Stomp broker address, default '%(default)s'",
            type=str,
            action=SetParameter,
        )
        argparser.add_argument(
            "--stomp-port",
            metavar="PORT",
            default=cls.defaults.get("--stomp-port"),
            help="Stomp broker port, default '%(default)s'",
            type=int,
            action=SetParameter,
        )
        argparser.add_argument(
            "--stomp-user",
            metavar="USER",
            default=cls.defaults.get("--stomp-user"),
            help="Stomp user, default '%(default)s'",
            type=str,
            action=SetParameter,
        )
        argparser.add_argument(
            "--stomp-pass",
            metavar="PASS",
            default=cls.defaults.get("--stomp-pass"),
            help="Stomp password",
            type=str,
            action=SetParameter,
        )
        argparser.add_argument(
            "--stomp-prfx",
            metavar="PRE",
            default=cls.defaults.get("--stomp-prfx"),
            help="Stomp namespace prefix, default '%(default)s'",
            type=str,
            action=SetParameter,
        )
        argparser.add_argument(
            "--stomp-conf",
            metavar="CNF",
            default=cls.defaults.get("--stomp-conf"),
            help="Stomp configuration file containing connection information, disables default values",
            type=str,
            action=SetParameter,
        )
1372089
function CommandArgLength(cmd) {
  this.name = CommandArgLength.name;
  if(arguments.length > 1) {
    cmd = slice.call(arguments, 0).join(' ');
  }
  StoreError.apply(
    this, [null, 'wrong number of arguments for \'%s\' command', cmd]);
}
650655
def initialize_cmd_args(args, name_args, new_name_args)
      args = args.dup
      args.shift(2 + name_args.length)
      new_name_args + args
    end
1108534
def add_supplied_query_arguments(parser):
    """"""
    parser.add_argument('-l', '--labels', help=constants.SUPPLIED_LABELS_HELP,
                        nargs='+', required=True)
    parser.add_argument('-s', '--supplied',
                        help=constants.SUPPLIED_RESULTS_HELP,
                        metavar='RESULTS', nargs='+', required=True)
1073900
def add_arguments(self, actions):
        
        actions = sorted(
            actions, key=operator.attrgetter('option_strings'))
        super(SortedHelpFormatter, self).add_arguments(actions)
421864
def AddArg(self, argument):
    
    self.args.append(argument)
    if len(self.args) > self.number_of_args:
      raise errors.ParseError('Too many arguments for this expression.')

    elif len(self.args) == self.number_of_args:
      return True

    return False
320859
def arguments(self, args=None):
        '''
        
        '''
        # permits deleting elements rather than using slices
        args = args and list(args) or []

        # match against all known/supported subcmds
        if self.subcmd == 'apply':
            # apply subcommand requires a manifest file to execute
            self.subcmd_args = [args[0]]
            del args[0]

        if self.subcmd == 'agent':
            # no arguments are required
            args.extend([
                'test'
            ])

        # finally do this after subcmd has been matched for all remaining args
        self.args = args
1359503
def add_arguments(parser, doc_str, add_base_url=True):
    """"""
    parser.description = doc_str
    parser.formatter_class = argparse.RawDescriptionHelpFormatter
    parser.add_argument("--debug", action="store_true", help="Debug level logging")
    parser.add_argument(
        "--cert-pub",
        dest="cert_pem_path",
        action="store",
        default=django.conf.settings.CLIENT_CERT_PATH,
        help="Path to PEM formatted public key of certificate",
    )
    parser.add_argument(
        "--cert-key",
        dest="cert_key_path",
        action="store",
        default=django.conf.settings.CLIENT_CERT_PRIVATE_KEY_PATH,
        help="Path to PEM formatted private key of certificate",
    )
    parser.add_argument(
        "--public", action="store_true", help="Do not use certificate even if available"
    )
    parser.add_argument(
        "--disable-server-cert-validation",
        action="store_true",
        help="Do not validate the TLS/SSL server side certificate of the source node (insecure)",
    )
    parser.add_argument(
        "--timeout",
        type=float,
        action="store",
        default=DEFAULT_TIMEOUT_SEC,
        help="Timeout for DataONE API calls to the source MN",
    )
    parser.add_argument(
        "--retries",
        type=int,
        action="store",
        default=DEFAULT_RETRY_COUNT,
        help="Retry DataONE API calls that raise HTTP level exceptions",
    )
    parser.add_argument(
        "--page-size",
        type=int,
        action="store",
        default=DEFAULT_PAGE_SIZE,
        help="Number of objects to retrieve in each list method API call to source MN",
    )
    parser.add_argument(
        "--major",
        type=int,
        action="store",
        help="Skip automatic detection of API major version and use the provided version",
    )
    parser.add_argument(
        "--max-concurrent",
        type=int,
        action="store",
        default=DEFAULT_MAX_CONCURRENT_TASK_COUNT,
        help="Max number of concurrent DataONE API",
    )
    if not add_base_url:
        parser.add_argument(
            "--baseurl",
            action="store",
            default=django.conf.settings.DATAONE_ROOT,
            help="Remote MN or CN BaseURL",
        )
    else:
        parser.add_argument("baseurl", help="Remote MN or CN BaseURL")
594054
def add_argument(self, *args, **kwargs):
        
        if not (('action' in kwargs) and (kwargs['action'] == 'help')):
            # make sure required parameter options were defined
            try:
                name = kwargs['dest']
                param_type = kwargs['type']
                optional = kwargs['optional']
            except KeyError as e:
                detail = "%s option required. " % e
                raise KeyError(detail)
            if optional and ('default' not in kwargs):
                detail = "A default value is required for optional parameters %s." % name
                raise KeyError(detail)

            # grab the default and help values
            default = None
            if 'default' in kwargs:
                default = kwargs['default']
            param_help = ""
            if 'help' in kwargs:
                param_help = kwargs['help']

            # set the ArgumentParser's action
            if param_type not in (str, int, float, bool, ChrisApp.path):
                detail = "unsupported type: '%s'" % param_type
                raise ValueError(detail)
            action = 'store'
            if param_type == bool:
                action = 'store_false' if default else 'store_true'
                del kwargs['default'] # 'default' and 'type' not allowed for boolean actions
                del kwargs['type']
            kwargs['action'] = action

            # store the parameters internally (param_type.__name__ to enable json serialization)
            param = {'name': name, 'type': param_type.__name__, 'optional': optional,
                     'flag': args[0], 'action': action, 'help': param_help, 'default': default}
            self._parameters.append(param)

            # add the parameter to the parser
            del kwargs['optional']
        ArgumentParser.add_argument(self, *args, **kwargs)
218678
def build_command(self, config, **kwargs):
        """"""
        command = ['perl', self.script, CLI_OPTIONS['config']['option'], config]
        for key, value in kwargs.items():
            # enable passing in flags as "False" - shouldn't add command
            if value:
                command.append(CLI_OPTIONS[key]['option'])
                if value is True:
                    command.append(CLI_OPTIONS[key].get('default', '1'))
                else:
                    command.append(value)
        return command
917068
def extend(self, cli_api, command_prefix="", sub_command="", **kwargs):
        """"""
        if sub_command and command_prefix:
            raise ValueError('It is not currently supported to provide both a command_prefix and sub_command')

        if sub_command:
            self.commands[sub_command] = cli_api
        else:
            for name, command in cli_api.commands.items():
                self.commands["{}{}".format(command_prefix, name)] = command
913481
def add_raw_arg(self, arg):
        
        if not isinstance(arg, File):
            arg = str(arg)

        self._raw_options += [arg]
965268
def add_argument(self, *args, **kwargs):
        
        defhelp = kwargs.pop("help", None)
        defaults = kwargs.pop("default", None)
        default = defaults if self.use_defaults else None
        if not defhelp or default is None or kwargs.get('action') == 'help':
            return super().add_argument(*args, help=defhelp, default=default, **kwargs)
        else:
            return super().add_argument(*args, help=defhelp + " (default: {})".format(default),
                                        default=default, **kwargs)
343119
def add(**kwargs):
  '''  '''

  output, err = cli_syncthing_adapter.add(**kwargs)
  click.echo("%s" % output, err=err)