See if the opt parser would think this is a short option ("-")
509242
private static boolean isShortOptionToken(final String argument) {
        return argument.startsWith( SHORT_OPTION_PREFIX )
                && !SHORT_OPTION_PREFIX.equals( argument )
                && !isLongOptionToken( argument );
    }
998812
def parser(self):
        
        usage = self.usage()
        if self.__doc__:
            usage += '\n' + nstr(self.__doc__)

        parse = PARSER_CLASS(usage=usage)

        shorts = {v: k for k, v in self.short_keys.items()}
        for key, default in self.cmd_opts.items():
            # default key, cannot be duplicated
            if key == 'help':
                continue

            try:
                short = '-' + shorts[key]
            except KeyError:
                short = ''

            if default is True:
                action = 'store_false'
            elif default is False:
                action = 'store_true'
            else:
                action = 'store'

            # add the option
            parse.add_option(short, '--%s' % key, action=action, default=default)

        return parse
1248290
def _parse_options(opts, delim):
    """"""
    options = {}
    for opt in opts.split(delim):
        key, val = opt.split("=")
        if key.lower() == 'readpreferencetags':
            options.setdefault('readpreferencetags', []).append(val)
        else:
            # str(option) to ensure that a unicode URI results in plain 'str'
            # option names. 'normalized' is then suitable to be passed as
            # kwargs in all Python versions.
            if str(key) in options:
                warnings.warn("Duplicate URI option %s" % (str(key),))
            options[str(key)] = unquote_plus(val)

    # Special case for deprecated options
    if "wtimeout" in options:
        if "wtimeoutMS" in options:
            options.pop("wtimeout")
        warnings.warn("Option wtimeout is deprecated, use 'wtimeoutMS'"
                      " instead")

    return options
1321661
def _arg2opt(arg):
    '''
    
    '''
    res = [o for o, a in option_toggles.items() if a == arg]
    res += [o for o, a in option_flags.items() if a == arg]
    return res[0] if res else None
758170
def _check_building_options(string):
    
    opener, closer = '{', '}'
    _check_enclosing_characters(string, opener, closer)
    if opener in string:
        if string[-1] != closer:
            raise ValueError(OPTIONS_NOT_LAST)
        ret = True
    else:
        ret = False
    return ret
613766
function parseOptions(opts) {
    opts = opts || {};
    if (toString.call(opts) === '[object String]') {
        opts = {
            directory: opts
        };
    }

    opts.cwd = opts.cwd || process.cwd();

    log.verbosity = toString.call(opts.verbosity) === '[object Number]' ? opts.verbosity : DEFAULT_VERBOSITY;
    delete (opts.verbosity);

    cmd = opts.cmd || DEFAULT_CMD;
    delete (opts.cmd);

    // enable bower prompting but ignore the actual prompt if interactive == false
    enablePrompt = opts.interactive || DEFAULT_INTERACTIVE;
    opts.interactive = true;

    if (!opts.directory) {
        opts.directory = getDirectoryFromBowerRc(opts.cwd) || DEFAULT_DIRECTORY;
    }

    return opts;
}
602261
def getopt ( opt )
      result = { :n => '', :t => '', }
      if opt.length > OPTION_PREFIX_LONG.length then
        if opt[0, OPTION_PREFIX_LONG.length] == OPTION_PREFIX_LONG then
          result[:n] = opt[OPTION_PREFIX_LONG.length, opt.length]
          result[:t] = OPTION_PREFIX_LONG
          return result
        end
      end
      if opt.length > OPTION_PREFIX_SHORT.length then
        if opt[0, OPTION_PREFIX_SHORT.length] == OPTION_PREFIX_SHORT then
          result[:n] = opt[OPTION_PREFIX_SHORT.length, opt.length]
          result[:t] = OPTION_PREFIX_SHORT
          return result 
        end
      end
      return result
    end
73350
function validateOptions(opt) {
    if (opt) {
        if (opt.hasOwnProperty('dir')) {
            if (opt.dir.length < 1 || typeof opt.dir !== 'string') {
                throw new TypeError('dir value must be a valid string');
            }
            if (!isValidString(opt.dir)) {
                throw new TypeError('only underscore is allowed in dir name');
            }
            options.dir = opt.dir || options.dir;
        }


        if (opt.hasOwnProperty('file')) {
            if ((opt.file.length < 1 || typeof opt.file !== 'string')) {
                throw new TypeError('file value must be a valid string');
            }
            if (!isValidString(opt.file)) {
                throw new TypeError('only underscore is allowed in file name');
            }
            options.file = opt.file || options.file;
        }

        if (opt.hasOwnProperty('dateWise')) {
            if (typeof opt.dateWise !== 'boolean') {
                throw new TypeError('dateWise must be a boolean');
            }
            options.dateWise = opt.dateWise || options.dateWise;
        }
    }
    if (options.dateWise === true) {
        todayDate = todayDate.concat(new Date().getDate(), '_', monthsName[new Date().getMonth()], '_', new Date().getFullYear());
        if (options.file.indexOf('.log') === -1) {
            options.file = String().concat(options.file, '_', todayDate, '.log');
        } else {
            options.file = String().concat(options.file, '_', todayDate);
        }

    } else {
        if (options.file.indexOf('.log') === -1) {
            options.file = String().concat(options.file, '.log');
        } else {
            options.file = String().concat(options.file);
        }
    }
    return options;
}
809778
def parse_options():
    

    try:
        opts, args = getopt.getopt(sys.argv[1:], 'ac:e:hilms:t:vx',
                ['adapt', 'comp=', 'enum=', 'exhaust', 'help', 'incr', 'blo',
                    'minimize', 'solver=', 'trim=', 'verbose'])
    except getopt.GetoptError as err:
        sys.stderr.write(str(err).capitalize())
        usage()
        sys.exit(1)

    adapt = False
    exhaust = False
    cmode = None
    to_enum = 1
    incr = False
    blo = False
    minz = False
    solver = 'g3'
    trim = 0
    verbose = 1

    for opt, arg in opts:
        if opt in ('-a', '--adapt'):
            adapt = True
        elif opt in ('-c', '--comp'):
            cmode = str(arg)
        elif opt in ('-e', '--enum'):
            to_enum = str(arg)
            if to_enum != 'all':
                to_enum = int(to_enum)
            else:
                to_enum = 0
        elif opt in ('-h', '--help'):
            usage()
            sys.exit(0)
        elif opt in ('-i', '--incr'):
            incr = True
        elif opt in ('-l', '--blo'):
            blo = True
        elif opt in ('-m', '--minimize'):
            minz = True
        elif opt in ('-s', '--solver'):
            solver = str(arg)
        elif opt in ('-t', '--trim'):
            trim = int(arg)
        elif opt in ('-v', '--verbose'):
            verbose += 1
        elif opt in ('-x', '--exhaust'):
            exhaust = True
        else:
            assert False, 'Unhandled option: {0} {1}'.format(opt, arg)

    return adapt, blo, cmode, to_enum, exhaust, incr, minz, solver, trim, \
            verbose, args
1163937
public boolean hasOption(String opt)
    {
        opt = Util.stripLeadingHyphens(opt);

        return shortOpts.containsKey(opt) || longOpts.containsKey(opt);
    }
1102848
function parseArguments(opts, callback) {
  if ('function' === typeof opts) {
    callback = opts
    opts = {}
  }

  opts = opts || {}
  opts.callback = callback

  return opts
}
1165338
function Untar(opts, cb) {
		if (typeof opts === 'function') {
			cb = opts;
			opts = {};
		}

		// I should probably actually add some options...
		opts = opts || {};

		this.fileTypes = filterDecoder(opts.filter);

		this.cb = cb;
	}
1017237
function opt(pattern, defval) {
        return new Pattern(pattern + '?', function (str, pos) {
            return pattern.exec(str, pos) || { res: defval, end: pos };
        });
    }
622477
function getOpts(input, optdef = null, config = {}){
	
	// Do nothing if given nothing
	if(!input || 0 === input.length)
		return {options: {}, argv: []};
	
	// Avoid modifying original array
	if(Array.isArray(input))
		input = [...input].map(String);
	
	// If called with a string, break it apart into an array
	else if("string" === typeof input)
		input = unstringify(input);
	
	
	// Take a different approach if optdefs aren't specified
	if(null === optdef || "" === optdef || false === optdef)
		return autoOpts(input, config);
	
	
	// Allow "t:h:i:s" style of getopt usage
	if("[object String]" === Object.prototype.toString.call(optdef)){
		const names = optdef.match(/[^\s:]:?/g);
		optdef = {};
		names.forEach(name => {
			optdef[`-${name.replace(/:/, "")}`] = name.length > 1 ? "<arg>" : "";
		});
	}

	// Parse settings that affect runtime option-handling
	const {
		noAliasPropagation,
		noCamelCase,
		noBundling,
		noMixedOrder,
		noUndefined,
		terminator,
		ignoreEquals,
		duplicates = "use-last",
	} = config;
	
	const shortNames = {};
	const longNames = {};
	const result = {argv: [], options: new Object(null)};

	// Define each named option. Throw an error if a duplicate is found.
	for(const name in optdef){
		const option = new Option(name, optdef[name]);
		
		for(const name of option.shortNames){
			if(undefined !== shortNames[name])
				throw new ReferenceError(`Short option "-${name}" already defined`);
			shortNames[`-${name}`] = option;
		}
		
		for(const name of option.longNames){
			if(undefined !== longNames[name])
				throw new ReferenceError(`Long option "--${name}" already defined`);
			longNames[`--${name}`] = option;
		}
	}
	
	// Pointer to the option that's currently picking up arguments
	let currentOption;
	
	
	// Manage duplicated option values
	function resolveDuplicate(option, name, value){
		switch(duplicates){
			
			// Use the first value (or set of values); discard any following duplicates
			case "use-first":
				return result.options[name];
			
			// Use the last value (or set of values); discard any preceding duplicates. Default.
			case "use-last":
			default:
				return result.options[name] = value;
			
			// Use the first/last options; treat any following/preceding duplicates as argv items respectively
			case "limit-first":
			case "limit-last":
				result.argv.push(option.prevMatchedName, ...arrayify(value));
				break;
			
			// Throw an exception
			case "error":
				const error = new TypeError(`Attempting to reassign option "${name}" with value(s) ${JSON.stringify(value)}`);
				error.affectedOption = option;
				error.affectedValue  = value;
				throw error;
			
			// Add parameters of duplicate options to the argument list of the first
			case "append":
				const oldValues = arrayify(result.options[name]);
				const newValues = arrayify(value);
				result.options[name] = oldValues.concat(newValues);
				break;
			
			// Store parameters of duplicated options in a multidimensional array
			case "stack": {
				let oldValues   = result.options[name];
				const newValues = arrayify(value);
				
				// This option hasn't been "stacked" yet
				if(!option.stacked){
					oldValues            = arrayify(oldValues);
					result.options[name] = [oldValues, newValues];
					option.stacked       = true;
				}
				
				// Already "stacked", so just shove the values onto the end of the array
				else result.options[name].push(arrayify(newValues));
				
				break;
			}
			
			// Store each duplicated value in an array using the order they appear
			case "stack-values": {
				let values = result.options[name];
				
				// First time "stacking" this option (nesting its value/s inside an array)
				if(!option.stacked){
					const stack = [];
					for(const value of arrayify(values))
						stack.push([value]);
					values = stack;
					option.stacked = true;
				}
				
				arrayify(value).forEach((v, i) => {
					
					// An array hasn't been created at this index yet,
					// because an earlier option wasn't given enough parameters.
					if(undefined === values[i])
						values[i] = Array(values[0].length - 1);
					
					values[i].push(v);
				});
				
				result.options[name] = values;
				break;
			}
		}
	}
	
	
	// Assign an option's parsed value to the result's `.options` property
	function setValue(option, value){
		
		// Assign the value only to the option name it matched
		if(noAliasPropagation){
			let name = option.lastMatchedName;
			
			// Special alternative:
			// In lieu of using the matched option name, use the first --long-name only
			if("first-only" === noAliasPropagation)
				name = option.longNames[0] || option.shortNames[0];
			
			// camelCase?
			name = formatName(name, noCamelCase);
			
			// This option's already been set before
			if(result.options[name])
				resolveDuplicate(option, name, value);
			
			else result.options[name] = value;
		}
		
		// Copy across every alias this option's recognised by
		else{
			const {names} = option;
			
			for(let name of names){
				
				// Decide whether to camelCase this option name
				name = formatName(name, noCamelCase);
				
				// Ascertain if this option's being duplicated
				if(result.options[name])
					resolveDuplicate(option, name, value);
				
				result.options[name] = value;
			}
		}
	}
	
	
	// Push whatever we've currently collected for this option and reset pointer
	function wrapItUp(){
		let optValue = currentOption.values;
		
		// Don't store solitary values in an array. Store them directly as strings
		if(1 === currentOption.arity && !currentOption.variadic)
			optValue = optValue[0];

		setValue(currentOption, optValue);
		currentOption.values = [];
		currentOption = null;
	}
	
	
	// Reverse the order of an argument list, keeping options and their parameter lists intact
	function flip(input){
		input = input.reverse();
		
		// Flip any options back into the right order
		for(let i = 0, l = input.length; i < l; ++i){
			const arg = input[i];
			const opt = shortNames[arg] || longNames[arg];
			
			if(opt){
				const from    = Math.max(0, i - opt.arity);
				const to      = i + 1;
				const extract = input.slice(from, to).reverse();
				input.splice(from, extract.length, ...extract);
			}
		}
		
		return input;
	}
	
	
	// Tackle bundling. Ensure there's at least one option with a short name to work with.
	const nameKeys = Object.keys(shortNames);
	let bundleMatch, bundlePatterns, niladicArgs;
	
	if(!noBundling && nameKeys.length){
		bundlePatterns  = uniqueStrings(nameKeys.map(n => shortNames[n].bundlePattern)).join("|");
		bundleMatch     = new RegExp(`^-(${bundlePatterns})+`, "g");
		niladicArgs     = uniqueStrings(nameKeys.filter(n => !shortNames[n].arity).map(n => shortNames[n].bundlePattern)).join("|");
		niladicArgs     = new RegExp(`^(-(?:${niladicArgs})+)((?!${bundlePatterns})\\S+)`);
		bundlePatterns  = new RegExp(bundlePatterns, "g");
	}
	
	
	// Is pre-processing of the argument list necessary?
	if(!ignoreEquals || bundleMatch){
		
		// Limit equals-sign expansion to items that begin with recognised option names
		const legalNames = new RegExp(`^(?:${ Object.keys(longNames).join("|") })=`);
		
		for(let i = 0, l = input.length; i < l; ++i){
			let arg = input[i];
			
			// We have bundling in use
			if(bundleMatch){
				bundleMatch.lastIndex = 0;
				
				// Expand bundled option clusters ("-mvl2" -> "-m -v -l 2")
				if(bundleMatch.test(arg)){
					
					// Break off arguments attached to niladic options
					const niladicMatch = arg.match(niladicArgs);
					if(niladicMatch){
						niladicArgs.lastIndex = 0;
						arg = niladicMatch[1];
						input.splice(i + 1, 0, niladicMatch[2]);
						l = input.length;
					}
					
					const segments = [].concat(...arg.match(bundlePatterns).map(m => {
						const option = shortNames[`-${m[0]}`];
						const result = [`-${m[0]}`];
						if(!option.arity) return result;
						result.push(...m.match(new RegExp(option.bundlePattern)).slice(1).filter(i => i));
						return result;
					}));
					input.splice(i, 1, ...segments);
					l =  input.length;
					i += segments.length - 1;
					continue;
				}
			}
			
			// Expand "--option=value" sequences to become "--option value"
			if(legalNames.test(arg)){
				const match = arg.match(/^([^=]+)=(.+)$/);
				input.splice(i, 1, match[1], match[2]);
				l =  input.length;
				i += 1;
			}
		}
	}
	
	
	// If we're handling duplicate options with "limit-last", flip the input order
	if("limit-last" === duplicates)
		input = flip(input);
	
	// Start processing the arguments we were given to handle
	for(let i = 0, l = input.length; i < l; ++i){
		const arg = input[i];
		const opt = shortNames[arg] || longNames[arg];
		
		// This argument matches a recognised option name
		if(opt){
			
			// Record the name given on command-line that matched the option
			opt.lastMatchedName = arg;
			
			// Did we have an existing option that was collecting values?
			if(currentOption) wrapItUp();
			
			
			// Option takes at least one argument
			if(opt.arity)
				currentOption = opt;
			
			// This option takes no arguments, so just assign it a value of "true"
			else setValue(opt, true);
			
			
			// Store an additional back-reference to the current option's name
			opt.prevMatchedName = arg;
		}
		
		else{
			const isTerminator = match(arg, terminator);
			const keepRest = () => result.argv.push(...input.slice(i + 1));
			
			// A previous option is still collecting arguments
			if(currentOption && currentOption.canCollect && !isTerminator)
				currentOption.values.push(arg);
			
			// Not associated with an option
			else{
				currentOption && wrapItUp();
				
				// Terminate option parsing?
				if(isTerminator){
					keepRest();
					break;
				}
				
				// Raise an exception if unrecognised switches are considered an error
				if(noUndefined && /^-./.test(arg)){
					let error = noUndefined;
					
					// Prepare an error object to be thrown in the user's direction
					switch(typeof noUndefined){
						case "function": error = error(arg); break;
						case "boolean":  error = 'Unknown option: "%s"'; // Fall-through
						case "string":   error = new TypeError(error.replace("%s", arg));
					}
					throw error;
				}
				
				result.argv.push(arg);
				
				// Finish processing if mixed-order is disabled
				if(noMixedOrder){
					keepRest();
					break;
				}
			}
		}
	}
	
	
	// Ended abruptly?
	if(currentOption) wrapItUp();
	
	
	// Check if we need to flip the returned .argv array back into the right order again
	if("limit-last" === duplicates)
		result.argv = flip(result.argv);
		
	return result;
}
766305
def hasOption(self, name):
    
    name = name.strip()
    for o in self.options:
      if o.short == name or o.long == name:
        return True
    return False
958259
function parseOptions(opts) {
  opts = opts || {};
  var argv = [];
  var options = {};
  var process_argv = process.argv;
  for (var i = 2; i < process_argv.length; i++) {
    if (process_argv[i].indexOf('--') == 0) {
      var arg = process_argv[i];
      if (arg.indexOf("=") > 0) {
        var arg_kv = arg.split('=');
        arg = arg_kv[0];
        arg = arg.replace('--','');
        arg = replaceAll(arg, '-', '_');
        options[arg] = arg_kv[1];
        if (typeof opts[arg] == 'string') {
          if (opts[arg] == 'int' || opts[arg] == 'integer') {
            options[arg] = parseInt(options[arg]);
          } else if (opts[arg] == 'float') {
            options[arg] = parseFloat(options[arg]);
          }
        } else if (typeof opts[arg] == 'object') {
          if (opts[arg].type == 'array') {
            var sep = opts[arg].separator || opts[arg].sep || ',';
            options[arg] = options[arg].split(sep);
          }
        }
      } else {
        arg = arg.replace('--','');
        arg = replaceAll(arg, '-', '_');
        options[arg] = true;
      }
    } else {
      argv.push(process_argv[i]);
    }
  }
  options.argv = argv;
  return options;
}
780110
function getOptionName (arg) {
  if (re.short.test(arg)) {
    return arg.match(re.short)[1]
  } else if (isLongOption(arg)) {
    return arg.match(re.long)[1]
  } else if (isOptionEqualsNotation(arg)) {
    return arg.match(re.optEquals)[1].replace(/^--/, '')
  } else {
    return null
  }
}