See if a particular command was passed to the script via the command line and return a value. Can either be the short or long version
@param  {String}       list of arguments to check

@return {String}       the value that was passed via the command line
518361
public static function findCommandValue($args) {
		$args = explode("|",$args);
		foreach ($args as $arg) {
			if (isset(self::$options[$arg])) {
				return self::$options[$arg];
			}
		}
		return false;
	}
1215694
def _get_cmd(command, arguments):
    """"""
    if arguments is None:
        arguments = []
    if command.endswith(".py") or command.endswith(".pyw"):
        return [sys.executable, command] + list(arguments)
    else:
        return [command] + list(arguments)
164436
function(command) {
        var patt = /("[^"]*")/,
            quotedStringPlaceholder = "__QUOTEDSTR__",
            escapedQuotePlaceholder = "__ESCAPED_QUOTE__",
            matches = [],
            match;

        command = command.replace(/\\\"/g, escapedQuotePlaceholder);

        while ((match = patt.exec(command))) {
            var matched = match[0];
            command =
                command.substr(0, match.index) + quotedStringPlaceholder + command.substr(match.index + matched.length);
            matches.push(matched.substring(1, matched.length - 1));
        }

        var parts = command.split(" ");
        parts = parts.map(function(part) {
            var item = part.trim();
            if (item === quotedStringPlaceholder) {
                item = matches.shift();
            }
            item = item.replace(new RegExp(escapedQuotePlaceholder, "g"), '"');
            return item;
        });

        return parts;
    }
1233510
def get_command(arguments):
    
    cmds = list(filter(lambda k: not (k.startswith('-') or
                                 k.startswith('<')) and arguments[k],
                  arguments.keys()))
    if len(cmds) != 1:
        raise Exception('invalid command line!')
    return cmds[0]
321052
function getCommands( str ){
	var commands = str.split('|');

	commands.forEach(function( command, key ){
		var args = command.split(':');

		args.forEach(function( arg, k ){
			args[k] = trim( arg );
		});

		commands[key] = {
			command: command,
			method: args.shift(),
			args: args
		};
	});

	return commands;
}
703192
function _parseForAutocomplete(fullCommandStr) {
    var fullCommandParsed = CommandParser.parse(fullCommandStr);
    var lastArg = _.last(fullCommandParsed.args);

    // If the last argument does not have an index, it means it's a cliff hanger (e.g., a space at
    // the end of the command string). Therefore, we'll assign it an index at the end of the input
    // string
    if (!_.isNumber(lastArg.i)) {
        lastArg.i = fullCommandStr.length;
    }

    return fullCommandParsed;
}
1011382
function GetCommandUsage(execName, packageJson, cmdSpec, args) {
  const argSpec = cmdSpec.argSpec || [];
  const optStr = argSpec.length ? ' [options]' : '';
  const header = `\
Usage:   ${execName} ${cmdSpec.name}${optStr}
Purpose: ${cmdSpec.desc}
Options: ${argSpec.length ? '' : 'none.'}`;

  const usageTableRows = _.map(cmdSpec.argSpec, (argDef) => {
    const dashify = flag => (flag.length === 1 ? `-${col.primary(flag)}` : `--${col.primary(flag)}`);
    const lhs = _.map(argDef.flags, dashify).join(', ');
    const rhs = argDef.desc || '';
    return [lhs, rhs, argDef];
  });

  const firstColWidth = _.max(
    _.map(usageTableRows, row => stripAnsi(row[0]).length)) + 1;

  const body = _.map(usageTableRows, (row) => {
    const rhsLines = row[1].split(/\n/mg);
    const firstRhsLine = rhsLines[0];
    rhsLines.splice(0, 1);

    const lhsSpacer = new Array((firstColWidth - stripAnsi(row[0]).length) + 1).join(' ');
    const paddedLhs = `${lhsSpacer}${row[0]}`;
    const firstLine = `${paddedLhs}: ${firstRhsLine}`;

    const skipLeft = new Array(firstColWidth + 1).join(' ');
    const paddedRhs = rhsLines.length ? _.map(rhsLines, line => `${skipLeft}${line}`).join('\n') : '';

    const argDef = row[2];
    let curVal = _.find(argDef.flags, flag => (flag in args ? args[flag] : null));
    if (!curVal) curVal = argDef.defVal || argDef.default || '';
    if (curVal) {
      curVal = `${skipLeft}  ${col.dim('Current:')} "${col.primary(curVal)}"`;
    }
    return _.filter([
      firstLine,
      paddedRhs,
      curVal,
    ]).join('\n');
  }).join('\n\n');

  return `\
${header}
${body}
`;
}
794078
def get_cmdline_varargs(argv=None):
    
    if argv is None:
        argv = sys.argv
    scriptname = argv[0]
    if scriptname == '':
        # python invoked by iteself
        pos_start = 0
        pos_end = 0
    else:
        pos_start = pos_end = 1
        for idx in range(pos_start, len(argv)):
            if argv[idx].startswith('-'):
                pos_end = idx
                break
        else:
            pos_end = len(argv)
    cmdline_varargs = argv[pos_start:pos_end]
    return cmdline_varargs
799402
function onArg(argName, index) {
		var idxMatch = argName.match(/^\$(\d+)$/);
		var paramMatch = argName.match(/^\$\$([A-Za-z0-9_-]+)$/);
		var flagMatch = argName.match(/^\$([A-Za-z0-9_-]+)$/);
		var paramName, idx;

		//always pass in shell as first
		if (index === 0) {
			if (secondPass)
				argValues[index] = shell;
		}
		//$args returns all remaining args
		else if (argName === "$args") {
			if (secondPass)
				argValues[index] = varArgs;
		}
		//$3 returns the 3th vararg
		else if (idxMatch) {
			if (secondPass)
				argValues[index] = varArgs[idxMatch[1]];
			else
				argsRequired = Math.max(argsRequired, idxMatch[1]);
		}
		//$$myArg should parse --my-arg value
		else if (paramMatch) {
			if (!secondPass) {
				paramName = utils.hyphenate(paramMatch[1]);
				validOptions.push("[" + paramName + " <value>]");
				idx = varArgs.indexOf(paramName);
				if (idx != -1) {
					if (idx >= varArgs.length - 1)
						throw "Missing a value for option " + paramName;
					argValues[index] = varArgs[idx + 1];
					varArgs.splice(idx, 2);
				}
			}
		}
		//$myFlag should parse --my-flag to true
		else if (flagMatch) {
			if (!secondPass) {
				paramName = utils.hyphenate(flagMatch[1]);
				validOptions.push("[" + paramName + "]");
				idx = varArgs.indexOf(paramName);
				argValues[index] = idx != -1;
				if (idx != -1)
					varArgs.splice(idx, 1);
			}
		}
		else if (argName.indexOf('$') === 0)
			throw new Error("Invalid parametername in nscript function: '" + argName + "', please check the nscript docs for valid parameter names");
		else if (secondPass)
			argValues[index] = shell.alias(argName);
	}
1215016
function getCompletions (str, list, isCmd) {
  var result = []
  list.forEach(function (f) {
    var a = isCmd ? npm.deref(f) : f
    if (result.indexOf(a) === -1 && f.indexOf(str) === 0) {
      result.push(a)
    }
  })
  return result
}
1310768
function commandExamples(examples) {
  if (!examples || !examples.length) {
    return ''
  }
  let exampleRender = `**Examples**${newLine}`
  exampleRender += '\`\`\`bash\n'
  examples.forEach((ex) => {
    console.log('ex', ex)
    exampleRender += `${ex}\n`
  })
  exampleRender += `\`\`\`${newLine}`
  return exampleRender
}
74538
function checkCommand (command, errorCallback) {
    var exec = command
    var args = this.argsExecutable
    var shell = false
    if (this.win) {
      // Arguments have to be manually quoted
      exec = `"${exec}"`
      args = args.map(a => `"${a}"`)
      shell = true
    }

    this.log.verbose(`- executing "${command}" to get executable path`)
    this.run(exec, args, shell, function (err, execPath) {
      // Possible outcomes:
      // - Error: not in PATH, not executable or execution fails
      // - Gibberish: the next command to check version will fail
      // - Absolute path to executable
      if (err) {
        this.addLog(`- "${command}" is not in PATH or produced an error`)
        return errorCallback(err)
      }
      this.addLog(`- executable path is "${execPath}"`)
      this.checkExecPath(execPath, errorCallback)
    }.bind(this))
  }
590095
function(command, argument) {
		/// <summary>
		/// Return the validations rules for the first selected element.
		/// </summary>
		/// <param name="command" type="String">
		/// Can be either "add" or "remove".
		/// </param>
		/// <param name="argument" type="">
		/// A list of rules to add or remove.
		/// </param>

		var element = this[0];
		
		if (command) {
			var settings = $.data(element.form, 'validator').settings;
			var staticRules = settings.rules;
			var existingRules = $.validator.staticRules(element);
			switch(command) {
			case "add":
				$.extend(existingRules, $.validator.normalizeRule(argument));
				staticRules[element.name] = existingRules;
				if (argument.messages)
					settings.messages[element.name] = $.extend( settings.messages[element.name], argument.messages );
				break;
			case "remove":
				if (!argument) {
					delete staticRules[element.name];
					return existingRules;
				}
				var filtered = {};
				$.each(argument.split(/\s/), function(index, method) {
					filtered[method] = existingRules[method];
					delete existingRules[method];
				});
				return filtered;
			}
		}
		
		var data = $.validator.normalizeRules(
		$.extend(
			{},
			$.validator.metadataRules(element),
			$.validator.classRules(element),
			$.validator.attributeRules(element),
			$.validator.staticRules(element)
		), element);
		
		// make sure required is at front
		if (data.required) {
			var param = data.required;
			delete data.required;
			data = $.extend({required: param}, data);
		}
		
		return data;
	}
406998
def argument(value, options = {})
      return unless @shell.applicable?(options)
      value = value.to_s
      if @shell.requires_escaping?(value)
        value = @shell.escape_value(value)
      end
      @command << ' ' << value
      @last_arg = :argument
    end
862872
function parse (argv, opts, target) {
  if ('string' === typeof argv) argv = argv.split(rSplit).filter(ignore);
  if (!opts) opts = {};
  opts[don] = true;
  var parsed = parseArray(argv, opts);
  opts[don] = false;
  var through = parsed[don].length ? parseArray(parsed[don], opts) : null;
  if (!target) target = {};
  target.options = parsed;
  target.commands = parsed[din];
  target.input = argv;
  if (through) {
    target.through = {
      options: through,
      commands: through[din]
    };
    delete through[din];
  }
  delete parsed[din];
  delete parsed[don];
  return target;
  function ignore (s) {
    return s && '' !== s;
  }
}
238527
async function getHelpContents(args, output) {
    if ('!' in args) {
        return getAllCommands(process.stdout);
    }

    if (args._.length == 0) {
        return getGeneralHelpContents(output);
    }
    else if (args._.length == 1) {
        return getVerbHelp(args._[0], output);
    } else if (args._.length >= 2) {
        const operation = getOperation(args._[0], args._[1]);
        if (operation) {
            output.write(`${operation.description}\n\n`);
            output.write(`Usage:\n${chalk.cyan.bold(operation.command)}\n\n`);
            return getHelpContentsForOperation(operation, output);
        } else {
            return getVerbHelp(args._[0], output);
        }
    }

    return getGeneralHelpContents(output);
}
209214
function validate(cmd, args, info) {
  AbstractCommand.prototype.validate.apply(this, arguments);
  var start
    , end;

  if(args.length !== 1 && args.length !== 3) {
    throw new CommandArgLength(cmd);
  }

  if(args.length > 1) {
    start = parseInt('' + args[1]);
    if(isNaN(start)) throw IntegerRange;
    args[1] = start;
    end = parseInt('' + args[2]);
    if(isNaN(end)) throw IntegerRange;
    args[2] = end;
  }
}