Parses the arguments used by exec methods.
Returns an array of parameters, containing also arguments as properties (query, params, consistency, options)
544785
function parseCommonArgs (query, params, consistency, options, callback) {
  var args = Array.prototype.slice.call(arguments);

  if (args.length < 2 || typeof args[args.length-1] !== 'function') {
    throw new Error('It should contain at least 2 arguments, with the callback as the last argument.');
  }

  if(args.length < 5) {
    options = null;
    callback = args[args.length-1];
    if (args.length < 4) {
      consistency = null;
      if (typeof params === 'number') {
        consistency = params;
        params = null;
      }
    }
    if (args.length < 3) {
      params = null;
    }
  }
  args.query = query;
  args.options = options;
  args.params = params;
  args.consistency = consistency;
  args.callback = callback;
  return args;
}
531015
def parse_arguments():
    

    parser = argparse.ArgumentParser()

    # Add options
    parser.add_argument(
        "-n", "--number", action="store", default=1000000, type=int,
        help="number of items")
    parser.add_argument(
        "-p", "--pause", action="store_true", help="pause after execution")

    # Parse command line
    return parser.parse_args(), parser
303238
def parse_arguments(arguments=sys.argv[1:]):
        
        args = docopt.docopt(doc="""
Smart File Sorter

Usage:
  sfp RULEFILE DIRECTORY [--debug] [--dry-run] [--log LOGFILE]
  sfp [--debug] --list-plugins

Options:
    RULEFILE        Rule configuration file to execute
    DIRECTORY       Directory of files to process
    --debug         Log extra information during processing
    --dry-run       Log actions but do not make any changes
    --log LOGFILE   Specify log output file
    --list-plugins  Print match and action plugin information
        """, argv=arguments)
        return args
930272
def parse_args():
    
    parser = argparse.ArgumentParser(description = 'Decrypt AEADs',
                                     add_help = True,
                                     formatter_class = argparse.ArgumentDefaultsHelpFormatter,
                                     )
    parser.add_argument('-v', '--verbose',
                        dest='verbose',
                        action='store_true', default=False,
                        help='Enable verbose operation',
                        )
    parser.add_argument('--debug',
                        dest='debug',
                        action='store_true', default=False,
                        help='Enable debug operation',
                        )
    parser.add_argument('--format',
                        dest='format',
                        default='raw',
                        help='Select output format (aead, raw or yubikey-csv)',
                        )
    parser.add_argument('--output-dir',
                        dest='output_dir',
                        help='Output dir basename (for --format aead)',
                        metavar='DIR',
                        )
    parser.add_argument('--print-filename',
                        dest='print_filename',
                        action='store_true', default=False,
                        help='Prefix each row with the AEAD filename',
                        )
    parser.add_argument('--key-handle',
                        dest='key_handle',
                        help='Key handle used when generating the AEADs.',
                        metavar='HANDLE',
                        )
    parser.add_argument('--key-handle-out',
                        dest='key_handle_out',
                        help='Key handle used when generating *new* AEADs (with --format aead).',
                        metavar='HANDLE',
                        )
    parser.add_argument('--aes-key',
                        dest='aes_key',
                        required=True,
                        help='AES key used when generating the AEADs.',
                        metavar='HEXSTR',
                        )
    parser.add_argument('--aes-key-out',
                        dest='aes_key_out',
                        required=False,
                        help='AES key used when generating *new* AEADs (with --format aead).',
                        metavar='HEXSTR',
                        )
    parser.add_argument('--start-public-id',
                        dest='start_id',
                        required=False, default=None,
                        help='The first public id to decrypt',
                        metavar='INT-OR-MODHEX',
                        )
    parser.add_argument('--stop-public-id',
                        dest='stop_id',
                        required=False, default=None,
                        help='The last public id to decrypt',
                        metavar='INT-OR-MODHEX',
                        )
    parser.add_argument('--fail-fast',
                        dest='fail_fast',
                        action='store_true', default=False,
                        help='Terminate on the first AEAD failure, rather than keep going.',
                        )
    parser.add_argument('paths',
                        nargs='+',
                        help='Files and/or directories to process.',
                        metavar='FILE-OR-DIR'
                        )
    args = parser.parse_args()
    # argument fixups
    args.format = args.format.lower()
    args.aes_key = args.aes_key.decode('hex')
    if args.key_handle:
        args.key_handle = pyhsm.util.key_handle_to_int(args.key_handle)
    if args.start_id is not None:
        try:
            n = int(args.start_id)
        except ValueError:
            hexstr = pyhsm.yubikey.modhex_decode(args.start_id)
            n = int(hexstr, 16)
        args.start_id = n
    if args.stop_id is not None:
        try:
            n = int(args.stop_id)
        except ValueError:
            hexstr = pyhsm.yubikey.modhex_decode(args.stop_id)
            n = int(hexstr, 16)
        args.stop_id = n
    # some checks
    if args.format == 'aead':
        if not args.output_dir:
            sys.stderr.write("error: --output-dir is required when using --format aead.\n")
            return False
        if not os.path.isdir(args.output_dir):
            sys.stderr.write("error: Output directory '%s' not found\n" % (args.output_dir))
            return False
        if not args.aes_key_out:
            sys.stderr.write("error: --aes-key-out is required when using --format aead.\n")
            return False
        if not args.key_handle_out:
            sys.stderr.write("error: --key-handle-out is required when using --format aead.\n")
            return False
        # argument fixups
        args.aes_key_out = args.aes_key_out.decode('hex')
        args.key_handle_out_orig = args.key_handle_out # save to use in AEAD output paths
        args.key_handle_out = pyhsm.util.key_handle_to_int(args.key_handle_out)
    return args
302068
def parse_args(cls):
        
        # Initialize configuration and userdata directories.
        dirs = appdirs.AppDirs(__title__, 'Mozilla Security')
        if not os.path.isdir(dirs.user_config_dir):
            shutil.copytree(os.path.join(cls.HOME, 'examples'), dirs.user_config_dir)
            shutil.copytree(os.path.join(cls.HOME, 'userdata'), os.path.join(dirs.user_config_dir, 'userdata'))

        parser = argparse.ArgumentParser(
            description='Laniakea Runtime v{}'.format(cls.VERSION),
            prog=__title__,
            add_help=False,
            formatter_class=lambda prog: argparse.ArgumentDefaultsHelpFormatter(prog, max_help_position=40, width=120),
            epilog='The exit status is 0 for non-failures and 1 for failures.')

        subparsers = parser.add_subparsers(dest='provider',
                                           description='Use -h to see the help menu of each provider.',
                                           title='Laniakea Cloud Providers',
                                           metavar='')

        modules = ModuleLoader()
        modules.load(cls.HOME, 'core/providers', 'laniakea')

        for name, module in modules.modules.items():
            globals()[name] = module

        for module, cli in modules.command_line_interfaces():
            getattr(module, cli).add_arguments(subparsers, dirs)

        base = parser.add_argument_group('Laniakea Base Parameters')
        base.add_argument('-verbosity',
                          default=2,
                          type=int,
                          choices=list(range(1, 6, 1)),
                          help='Log sensitivity.')

        base.add_argument('-focus',
                          action='store_true',
                          default=True,
                          help=argparse.SUPPRESS)

        base.add_argument('-settings',
                          metavar='path',
                          type=argparse.FileType(),
                          default=os.path.join(dirs.user_config_dir, 'laniakea.json'),
                          help='Laniakea core settings.')

        base.add_argument('-h', '-help', '--help',
                          action='help',
                          help=argparse.SUPPRESS)

        base.add_argument('-version',
                          action='version',
                          version='%(prog)s {}'.format(cls.VERSION),
                          help=argparse.SUPPRESS)

        userdata = parser.add_argument_group('UserData Parameters')
        userdata.add_argument('-userdata',
                              metavar='path',
                              type=argparse.FileType(),
                              help='UserData script for the provisioning process.')

        userdata.add_argument('-list-userdata-macros',
                              action='store_true',
                              help='List available macros.')

        userdata.add_argument('-print-userdata',
                              action='store_true',
                              help='Print the UserData script to stdout.')

        userdata.add_argument('-userdata-macros',
                              metavar='k=v',
                              nargs='+',
                              type=str,
                              help='Custom macros for the UserData.')

        return parser.parse_args()
244831
def _get_args(self, executable, *args):
        """"""
        args = list(args)
        args.insert(0, executable)
        if self.username:
            args.append("--username={}".format(self.username))
        if self.host:
            args.append("--host={}".format(self.host))
        if self.port:
            args.append("--port={}".format(self.port))

        args.append(self.dbname)
        #args.extend(other_args)
        return args
490207
def build_argument_parser(executable):
    

    a = ArgumentParser()
    a.add_argument("--xml", action="store_true", dest="__xml__", help="show cli xml")

    for p in executable:
        o = []
        if p.flag: o.append("-%s" % p.flag)
        if p.longflag: o.append("--%s" % p.longflag)
        a.add_argument(
            *o,
            metavar=p.type.upper(),
            dest=p.name,
            action="store",
            help=(p.description.strip() or "parameter %s" % p.name)
        )

    return a
810991
def get_parameters(self):
        
        import argparse
        parser = argparse.ArgumentParser(add_help=False)

        # without parameter
        parser.add_argument("-i", "--interactive", action="store_true", dest="stdin_open")
        parser.add_argument("-d", "--detach", action="store_true", dest="detach")
        parser.add_argument("-t", "--tty", action="store_true", dest="tty")
        parser.add_argument("--init", action="store_true", dest="init")
        parser.add_argument("--privileged", action="store_true", dest="privileged")
        parser.add_argument("-P", "--publish-all", action="store_true", dest="publish_all_ports")
        parser.add_argument("--read-only", action="store_true", dest="read_only")
        parser.add_argument("--rm", action="store_true", dest="remove")

        # string parameter
        parser.add_argument("--entrypoint", action="store", dest="entrypoint")
        parser.add_argument("-h", "--hostname", action="store", dest="hostname")
        parser.add_argument("--name", action="store", dest="name")
        parser.add_argument("--ipc", action="store", dest="ipc_mode")
        parser.add_argument("--isolation", action="store", dest="isolation")
        parser.add_argument("--mac-address", action="store", dest="mac_address")
        parser.add_argument("-m", "--memory", action="store", dest="mem_limit")
        parser.add_argument("--network", action="store", dest="network")
        parser.add_argument("--platform", action="store", dest="platform")
        parser.add_argument("--runtime", action="store", dest="runtime")
        parser.add_argument("--stop-signal", action="store", dest="stop_signal")
        parser.add_argument("-u", "--user", action="store", dest="user")
        parser.add_argument("-w", "--workdir", action="store", dest="working_dir")

        # int parameter
        parser.add_argument("--pids-limit", action="store", dest="pids_limit", type=int)

        # list parameter
        parser.add_argument("-e", "--env", action="append", dest="env_variables")
        parser.add_argument("--cap-add", action="append", dest="cap_add")
        parser.add_argument("--cap-drop", action="append", dest="cap_drop")
        parser.add_argument("--device", action="append", dest="devices")
        parser.add_argument("--dns", action="append", dest="dns")
        parser.add_argument("--group-add", action="append", dest="group_add")
        parser.add_argument("--mount", action="append", dest="mounts")
        parser.add_argument("-v", "--volume", action="append", dest="volumes")

        # dict parameter
        parser.add_argument("-l", "--label", action="append", dest="labels")
        parser.add_argument("-p", "--publish", action="append", dest="port_mappings")

        # health
        parser.add_argument("--health-cmd", action="store", dest="health_cmd")
        parser.add_argument("--health-interval", action="store", dest="health_interval", type=int)
        parser.add_argument("--health-retries", action="store", dest="health_retries", type=int)
        parser.add_argument("--health-timeout", action="store", dest="health_timeout", type=int)
        parser.add_argument("--no-healthcheck", action="store_true", dest="no_healthcheck")

        args, _ = parser.parse_known_args(args=self.options)
        command = self.arguments

        options_dict = vars(args)

        # create Healthcheck object
        if not options_dict.pop("no_healthcheck", None):
            options_dict["healthcheck"] = Healthcheck(
                test=options_dict.pop("health_cmd", None),
                interval=options_dict.pop("health_interval", None),
                timeout=options_dict.pop("health_timeout", None),
                retries=options_dict.pop("health_retries", None)
            )
        else:
            options_dict['healthcheck'] = None

        # parse dictionary
        # {'name': 'separator'}
        with_dictionary_parameter = {'labels': '='}
        for name, separator in with_dictionary_parameter.items():
            if options_dict[name] is not None:
                dictionary = {}
                for item in options_dict[name]:
                    try:
                        key, value = item.split(separator)
                        dictionary[key] = value
                    except ValueError:
                        dictionary = options_dict[name]
                        raise ConuException('Wrong format of dictionary: {name}'.format(name=name))
                        break
                options_dict[name] = dictionary

        # parse ports
        # create dictionary according to https://docker-py.readthedocs.io/en/stable/containers.html
        if options_dict['port_mappings'] is not None:
            dictionary = {}
            for port_string in options_dict['port_mappings']:
                colon_count = port_string.count(':')
                if colon_count == 2:
                    split_array = port_string.split(':')
                    if split_array[1] == '':
                        # format - ip::containerPort
                        # create dictionary - {'1111/tcp': ('127.0.0.1', None)}
                        dictionary[split_array[2]] = (split_array[0], None)
                    else:
                        # format - ip:hostPort:containerPort
                        # create dictionary - {'1111/tcp': ('127.0.0.1', 1111)}
                        dictionary[split_array[2]] = (split_array[0], int(split_array[1]))
                elif colon_count == 1:
                    # format - hostPort:containerPort
                    # create dictionary - {'2222/tcp': 3333}
                    split_array = port_string.split(':')
                    dictionary[split_array[1]] = int(split_array[0])
                elif colon_count == 0:
                    # format - containerPort
                    # create dictionary - {'2222/tcp': None}
                    dictionary[port_string] = None
                else:
                    raise ConuException('Wrong format of port mappings')

            options_dict['port_mappings'] = dictionary

        container_parameters = DockerContainerParameters(cap_add=options_dict['cap_add'],
                                                         cap_drop=options_dict['cap_drop'],
                                                         command=command, detach=options_dict['detach'],
                                                         devices=options_dict['devices'], dns=options_dict['dns'],
                                                         entrypoint=options_dict['entrypoint'],
                                                         env_variables=options_dict['env_variables'],
                                                         group_add=options_dict['group_add'],
                                                         healthcheck=options_dict['healthcheck'],
                                                         hostname=options_dict['hostname'],
                                                         init=options_dict['init'],
                                                         ipc_mode=options_dict['ipc_mode'],
                                                         isolation=options_dict['isolation'],
                                                         labels=options_dict['labels'],
                                                         mac_address=options_dict['mac_address'],
                                                         mem_limit=options_dict['mem_limit'],
                                                         mounts=options_dict['mounts'],
                                                         name=options_dict['name'],
                                                         network=options_dict['network'],
                                                         pids_limit=options_dict['pids_limit'],
                                                         platform=options_dict['platform'],
                                                         port_mappings=options_dict['port_mappings'],
                                                         privileged=options_dict['privileged'],
                                                         publish_all_ports=options_dict['publish_all_ports'],
                                                         read_only=options_dict['read_only'],
                                                         remove=options_dict['remove'],
                                                         runtime=options_dict['runtime'],
                                                         stdin_open=options_dict['stdin_open'],
                                                         stop_signal=options_dict['stop_signal'],
                                                         tty=options_dict['tty'],
                                                         user=options_dict['user'],
                                                         volumes=options_dict['volumes'],
                                                         working_dir=options_dict['working_dir']
                                                         )

        return container_parameters
920468
private String[] parseParams(String line) {
        //JENKINS-24870 CommandLine.getExecutable tries to fix file separators, so if the first param contains slashes, it can cause problems
        //Adding some placeholder instead of executable
        CommandLine cmdLine = CommandLine.parse("executable_placeholder " + line);
        String[] parsedArgs = cmdLine.getArguments();
        String[] args = new String[parsedArgs.length];
        if(parsedArgs.length > 0) {
            System.arraycopy(parsedArgs, 0, args, 0, parsedArgs.length);
        }
        return args;
    }
1225772
private void parseArgs(String[] args) {
        int index = 0;
        while (index < args.length) {
            String name = args[index];
            if (name.equals("-?") || name.equalsIgnoreCase("-help")) {
                usage();
            }
            if (name.charAt(0) != '-') {
                m_logger.error("Unrecognized parameter: {}", name);
                usage();
            }
            if (++index >= args.length) {
                m_logger.error("Another parameter expected after '{}'", name);
                usage();
            }
            String value = args[index];
            try {
                m_config.set(name.substring(1), value);
            } catch (Exception e) {
                m_logger.error(e.toString());
                usage();
            }
            index++;
        }
    }
352270
def parse_arguments():
    
    parser = argparse.ArgumentParser()

    parser.add_argument('file', metavar="FILE", nargs='+',
                        help='file to be made executable')
    parser.add_argument("-p", "--python", metavar="VERSION",
                        help="python version (2 or 3)")
    parser.add_argument('-v', '--version', action='version',
                        version='%(prog)s ' + __version__, help='show version')
    parser.add_argument('-r', '--recursive', action='store_true',
                        help='recursively iterate the directories')

    args = parser.parse_args()
    return args
781493
def _parse_args():
    
    parser = argparse.ArgumentParser(description='rain - a new sort of automated builder.')
    
    parser.add_argument('action', help='what shall we do?', default='build', nargs='?',
                        choices=['build',
                                 'ls',
                                 'keep'] + removal_cmds)

    parser.add_argument('-c', '--count', type=int, default=1,
                        help='a count of items on which to operate. [default: %(default)s]')

    parser.add_argument('--keep', type=int, default=-1,
                        help='how many builds should we keep around? [default: %(default)s]')

    parser.add_argument('-v', '--verbose', action='count', default=0, help='Be more verbose. (can be repeated)')

    parser.add_argument('--version', default=False, action='store_true',
                        help='print version number and exit. [default: %(default)s]')

    return parser.parse_args()
1164702
def get_query_arguments(self, name: str, strip: bool = True) -> List[str]:
        
        return self._get_arguments(name, self.request.query_arguments, strip)
642853
def parse_params(params)
      args = params.split(/\s+/).map(&:strip)
      invalid_args!(args) unless args.any?

      if args[0].to_s == OEMBED_ARG # TODO: remove after deprecation cycle
        arguments_deprecation_warning(args)
        args.shift
      end

      url, *api_args = args
      ApiRequest.new(url, parse_args(api_args))
    end
1276688
def parse_options(args)
      config = {}
      deprecated_args = []
      flag = /^--/

      args.size.times do
        break if args.empty?
        peek = args.first
        next unless peek && (peek.match(flag) || peek.match(/=/))
        arg  = args.shift
        peek = args.first
        key  = arg
        if key.match(/=/)
          deprecated_args << key unless key.match(flag)
          key, value = key.split('=', 2)
        elsif peek.nil? || peek.match(flag)
          value = true
        else
          value = args.shift
        end
        value = true if value == 'true'
        config[key.sub(flag, '')] = value

        if !deprecated_args.empty?
          out_string = deprecated_args.map{|a| "--#{a}"}.join(' ')
          display("Warning: non-unix style params have been deprecated, use #{out_string} instead")
        end
      end

      config
    end
920723
def parseargs(argv):
    ''''''
    args = []
    options = {}
    key = None
    for arg in argv:
        if arg in DEFAULT_OPTION_VALUES:
            key = arg.strip('=').replace('-', '_')
            options[key] = ()
        elif key is None:
            args.append(arg)
        else:
            options[key] += (arg,)

    if set(args) & {'-h', '--help'}:
        print(__doc__, end='')
        exit(0)
    elif set(args) & {'-V', '--version'}:
        print(__version__)
        exit(0)
    elif args:
        exit('invalid option: %s\nTry --help for more information.' % args[0])

    return options
353938
def getArguments():
    
    parser = ArgumentParser(description = 'CA utility')
    parser.add_argument('--base', dest = 'basePath', default = '.', help = 'The base working directory')
    subParsers = parser.add_subparsers(dest = 'action')
    # The init parser
    initParser = subParsers.add_parser('init', help = 'Initialize the database')
    # Vertify certificatae
    verifyParser = subParsers.add_parser('verify', help = 'Verify certificate')
    verifyParser.add_argument('--name', dest = 'name', required = True, help = 'The certificate name')
    # Create root certificate parser
    createRootCertParser = subParsers.add_parser('createRootCert', help = 'Create root certificate')
    createRootCertParser.add_argument('--nopass', dest = 'noPass', default = False, action = 'store_true', help = 'Generate root key without a password (Not recommended), false by default.')
    createRootCertParser.add_argument('--keylen', dest = 'keyLength', default = '4096', choices = [ '2048', '4096' ], help = 'The root key length, 4096 by default')
    # Create server certificate parser
    createServerCertParser = subParsers.add_parser('createServerCert', help = 'Create server cert')
    createServerCertParser.add_argument('--name', dest = 'name', required = True, help = 'The certificate name')
    createServerCertParser.add_argument('--usepass', dest = 'usePass', default = False, action = 'store_true', help = 'Generate key with a password, false by default.')
    createServerCertParser.add_argument('--keylen', dest = 'keyLength', default = '2048', choices = [ '2048', '4096' ], help = 'The key length, 2048 by default')
    createServerCertParser.add_argument('--days', dest = 'days', type = int, default = 3650, help = 'The certificate days parameter')
    # Create client certificate parser
    createClientCertParser = subParsers.add_parser('createClientCert', help = 'Create server cert')
    createClientCertParser.add_argument('--name', dest = 'name', required = True, help = 'The certificate name')
    createClientCertParser.add_argument('--usepass', dest = 'usePass', default = False, action = 'store_true', help = 'Generate key with a password, false by default.')
    createClientCertParser.add_argument('--keylen', dest = 'keyLength', default = '2048', choices = [ '2048', '4096' ], help = 'The key length, 2048 by default')
    createClientCertParser.add_argument('--days', dest = 'days', type = int, default = 3650, help = 'The certificate days parameter')
    # Done
    return parser.parse_args()