Parse remaining arguments after the ToolRunner args have already been removed.
@param args Argument list
332164
String[] parseArgs(String[] args) {
    int i = 0;
    boolean driverArgs = true;
    while (driverArgs) {
      if (i >= args.length) {
        break;
      }

      String s = args[i];
      if (s.equals("-h") ||
              s.equals("help") ||
              s.equals("-help") ||
              s.equals("--help")) {
        usage();
      }
      else if (s.equals("-n") ||
              s.equals("-nodes")) {
        i++; if (i >= args.length) { usage(); }
        numNodes = Integer.parseInt(args[i]);
      }
      else if (s.equals("-o") ||
              s.equals("-output")) {
        i++; if (i >= args.length) { usage(); }
        outputPath = args[i];
      }
      else if (s.equals("-jobname")) {
        i++; if (i >= args.length) { usage(); }
        jobtrackerName = args[i];
      }
      else if (s.equals("-mapperXmx")) {
        i++; if (i >= args.length) { usage(); }
        mapperXmx = args[i];
      }
      else if (s.equals("-extramempercent")) {
        i++; if (i >= args.length) { usage(); }
        extraMemPercent = Integer.parseInt(args[i]);
      }
      else if (s.equals("-mapperPermSize")) {
        i++; if (i >= args.length) { usage(); }
        mapperPermSize = args[i];
      }
      else if (s.equals("-driverif")) {
        i++; if (i >= args.length) { usage(); }
        driverCallbackIp = args[i];
      }
      else if (s.equals("-driverport")) {
        i++; if (i >= args.length) { usage(); }
        driverCallbackPort = Integer.parseInt(args[i]);
      }
      else if (s.equals("-driverportrange")) {
        i++; if (i >= args.length) { usage(); }
        driverCallbackPortRange = PortRange.parse(args[i]);
      }
      else if (s.equals("-network")) {
        i++; if (i >= args.length) { usage(); }
        network = args[i];
      }
      else if (s.equals("-timeout")) {
        i++; if (i >= args.length) { usage(); }
        cloudFormationTimeoutSeconds = Integer.parseInt(args[i]);
      }
      else if (s.equals("-disown")) {
        disown = true;
      }
      else if (s.equals("-notify")) {
        i++; if (i >= args.length) { usage(); }
        clusterReadyFileName = args[i];
      }
      else if (s.equals("-nthreads")) {
        i++; if (i >= args.length) { usage(); }
        nthreads = Integer.parseInt(args[i]);
      }
      else if (s.equals("-context_path")) {
        i++; if (i >= args.length) { usage(); }
        contextPath = args[i];
      }
      else if (s.equals("-baseport")) {
        i++; if (i >= args.length) { usage(); }
        basePort = Integer.parseInt(args[i]);
        if ((basePort < 0) || (basePort > 65535)) {
            error("Base port must be between 1 and 65535");
        }
      }
      else if (s.equals("-port_offset")) {
        i++; if (i >= args.length) { usage(); }
        portOffset = Integer.parseInt(args[i]);
        if ((portOffset <= 0) || (portOffset > 65534)) {
          error("Port offset must be between 1 and 65534");
        }
      }
      else if (s.equals("-beta")) {
        beta = true;
      }
      else if (s.equals("-random_udp_drop")) {
        enableRandomUdpDrop = true;
      }
      else if (s.equals("-ea")) {
        enableExceptions = true;
      }
      else if (s.equals("-verbose:gc") && !JAVA_VERSION.useUnifiedLogging()) {
        if (!JAVA_VERSION.useUnifiedLogging()) {
          enableVerboseGC = true;
        } else {
          error("Parameter -verbose:gc is unusable, running on JVM with deprecated GC debugging flags.");
        }
      } else if (s.equals("-Xlog:gc=info")) {
        if (JAVA_VERSION.useUnifiedLogging()) {
          enableVerboseGC = true;
        } else {
          error("Parameter -verbose:gc is unusable, running on JVM without unified JVM logging.");
        }
      }
      else if (s.equals("-verbose:class")) {
        enableVerboseClass = true;
      }
      else if (s.equals("-XX:+PrintCompilation")) {
        enablePrintCompilation = true;
      }
      else if (s.equals("-exclude")) {
        enableExcludeMethods = true;
      }
      else if (s.equals("-Dlog4j.defaultInitOverride=true")) {
        enableLog4jDefaultInitOverride = true;
      }
      else if (s.equals("-debug")) {
        enableDebug = true;
      }
      else if (s.equals("-suspend")) {
        enableSuspend = true;
      }
      else if (s.equals("-debugport")) {
        i++; if (i >= args.length) { usage(); }
        debugPort = Integer.parseInt(args[i]);
        if ((debugPort < 0) || (debugPort > 65535)) {
          error("Debug port must be between 1 and 65535");
        }
      } else if (s.equals("-XX:+PrintGCDetails")) {
        if (!JAVA_VERSION.useUnifiedLogging()) {
          enablePrintGCDetails = true;
        } else {
          error("Parameter -XX:+PrintGCDetails is unusable, running on JVM with deprecated GC debugging flags.");
        }
      }
      else if (s.equals("-XX:+PrintGCTimeStamps")) {
        if (!JAVA_VERSION.useUnifiedLogging()) {
          enablePrintGCDetails = true;
        } else {
          error("Parameter -XX:+PrintGCTimeStamps is unusable, running on JVM with deprecated GC debugging flags.");
        }
      }
      else if (s.equals("-gc")) {
        enableVerboseGC = true;
        enablePrintGCDetails = true;
        enablePrintGCTimeStamps = true;
      }
      else if (s.equals("-nogc")) {
        enableVerboseGC = false;
        enablePrintGCDetails = false;
        enablePrintGCTimeStamps = false;
      }
      else if (s.equals("-flow_dir")) {
        i++; if (i >= args.length) { usage(); }
        flowDir = args[i];
      }
      else if (s.equals("-J")) {
        i++; if (i >= args.length) { usage(); }
        extraArguments.add(args[i]);
      }
      else if (s.equals("-JJ")) {
        i++; if (i >= args.length) { usage(); }
        extraJvmArguments.add(args[i]);
      }
      else if (s.equals("-jks")) {
        i++; if (i >= args.length) { usage(); }
        jksFileName = args[i];
      }
      else if (s.equals("-jks_pass")) {
        i++; if (i >= args.length) { usage(); }
        jksPass = args[i];
      }
      else if (s.equals("-internal_secure_connections")) {
        internal_secure_connections = true;
      }
      else if (s.equals("-internal_security_conf") || s.equals("-internal_security")) {
        if(s.equals("-internal_security")){
          System.out.println("The '-internal_security' configuration is deprecated. " +
                  "Please use '-internal_security_conf' instead.");
        }
        i++; if (i >= args.length) { usage(); }
        securityConf = args[i];
      }
      else if (s.equals("-hash_login")) {
        hashLogin = true;
      }
      else if (s.equals("-ldap_login")) {
        ldapLogin = true;
      }
      else if (s.equals("-kerberos_login")) {
        kerberosLogin = true;
      }
      else if (s.equals("-pam_login")) {
        pamLogin = true;
      }
      else if (s.equals("-login_conf")) {
        i++; if (i >= args.length) { usage(); }
        loginConfFileName = args[i];
      }
      else if (s.equals("-form_auth")) {
        formAuth = true;
      }
      else if (s.equals("-session_timeout")) {
        i++; if (i >= args.length) { usage(); }
        sessionTimeout = args[i];
      }
      else if (s.equals("-user_name")) {
        i++; if (i >= args.length) { usage(); }
        userName = args[i];
      }
      else if (s.equals("-client")) {
        client = true;
        driverArgs = false;
      }
      else if (s.equals("-proxy")) {
        proxy = true;
        driverArgs = false;
      } else if (s.equals("-run_as_user")) {
        i++; if (i >= args.length) { usage(); }
        runAsUser = args[i];
      } else if (s.equals("-principal")) {
        i++; if (i >= args.length) { usage(); }
        principal = args[i];
      } else if (s.equals("-keytab")) {
        i++; if (i >= args.length) { usage (); }
        keytabPath = args[i];
      } else if (s.equals("-report_hostname")) {
        reportHostname = true;
      } else if (s.equals("-driver_debug")) {
        driverDebug = true;
      } else if (s.equals("-hiveHost")) {
        i++; if (i >= args.length) { usage (); }
        hiveHost = args[i];
      } else if (s.equals("-hivePrincipal")) {
        i++; if (i >= args.length) { usage (); }
        hivePrincipal = args[i];
      } else if (s.equals("-refreshTokens")) {
        refreshTokens = true;
      } else {
        error("Unrecognized option " + s);
      }

      i++;
    }
    String[] otherArgs = new String[Math.max(args.length - i, 0)];
    for (int j = 0; j < otherArgs.length; j++)
      otherArgs[j] = args[i++];
    return otherArgs;
  }
180934
private static void parseOptions(String args[])
  {
    if (!(args.length == 14 || args.length == 12 || args.length == 5)) {
      usage();
    }

    /*
     * As described in usage():
     * -s dfs-server
     * -p dfs-port [-t [create|create-write|stat|readdir|read|rename|delete]
     * -a planfile-path
     * -c host
     * -n process-name
     * -P prefix
     */
    for (int i = 0; i < args.length; i++) {
      if (args[i].equals("-s") && i+1 < args.length) {
        dfsServer_ = args[i+1];
        System.out.println(args[i+1]);
        i++;
      } else if (args[i].equals("-p") && i+1 < args.length) {
        dfsPort_ = Integer.parseInt(args[i+1]);
        System.out.println(args[i+1]);
        i++;
      } else if (args[i].equals("-t") && i+1 < args.length) {
        testName_ = args[i+1];
        System.out.println(args[i+1]);
        i++;
      } else if (args[i].equals("-a") && i+1 < args.length) {
        planfilePath_ = args[i+1];
        System.out.println(args[i+1]);
        i++;
      } else if (args[i].equals("-c") && i+1 < args.length) {
        hostName_ = args[i+1];
        System.out.println(args[i+1]);
        i++;
      } else if (args[i].equals("-n") && i+1 < args.length) {
        processName_ = args[i+1];
        System.out.println(args[i+1]);
        i++;
      } else if (args[i].equals("-P") && i+1 < args.length) {
        prefix_ = args[i+1];
        System.out.println(args[i+1]);
        i++;
      }
    }

    if (dfsServer_.length() == 0    ||
        testName_.length() == 0     ||
        planfilePath_.length() == 0 ||
        hostName_.length() == 0     ||
        processName_.length() == 0  ||
        dfsPort_ == 0) {
      usage();
    }
    if (prefix_ == null) {
      prefix_ = new String("PATH_PREFIX_");
    }
    prefixLen_ = prefix_.length();
  }
1312951
public static void logCommandLineArguments( String[] args ) {
		if( args == null || args.length < 1 ) return;
		for( int i=0; i < args.length; i++ ) {
			logMessage("Cmd line arg["+i+"]="+args[i]);
		}
	}
108723
public void setDeleteArguments(java.util.Collection<String> deleteArguments) {
        if (deleteArguments == null) {
            this.deleteArguments = null;
            return;
        }

        this.deleteArguments = new java.util.ArrayList<String>(deleteArguments);
    }
747352
private static void appendArgument(StringBuilder argumentsAsString, int index, String argumentName,
                                       Object[] arguments) {
        argumentsAsString.append(argumentName);
        if (index != arguments.length - 1) {
            argumentsAsString.append(", ");
        }
    }
615458
public void fillArguments(@Nonnull @MustNotContainNull final List<ExpressionTree> arguments) {
    assertNotEmptySlot();

    if (arguments == null) {
      throw new PreprocessorException("[Expression]Argument list is null", this.sourceString, this.includeStack, null);
    }

    if (childElements.length != arguments.size()) {
      throw new PreprocessorException("Wrong argument list size", this.sourceString, this.includeStack, null);
    }

    int i = 0;
    for (ExpressionTree arg : arguments) {
      if (arg == null) {
        throw new PreprocessorException("[Expression]Argument [" + (i + 1) + "] is null", this.sourceString, this.includeStack, null);
      }

      if (!childElements[i].isEmptySlot()) {
        throw new PreprocessorException("[Expression]Non-empty slot detected, it is possible that there is a program error, contact a developer please", this.sourceString, this.includeStack, null);
      }

      final ExpressionTreeElement root = arg.getRoot();
      if (root.isEmptySlot()) {
        throw new PreprocessorException("[Expression]Empty argument [" + (i + 1) + "] detected", this.sourceString, this.includeStack, null);
      }
      childElements[i] = root;
      root.parentTreeElement = this;

      i++;
    }
  }
1047515
public void parseAndEmit(String[] args) {
    	logger.finest("Checking command line arguments.");
        if (args.length != 2) {
        	final String version = new Version().getVersion();
        	logger.info("jADT version " + version + ".");
        	logger.info("Not enough arguments provided to jADT");
        	logger.info("usage: java sfdc.adt.JADT [source file or directory with .jadt files] [output directory]");
            throw new IllegalArgumentException("\njADT version " + version + "\nusage: java sfdc.adt.JADT [source file or directory with .jadt files] [output directory]");
        }
        
        final String srcPath = args[0];
        final String destDirName = args[1];

        parseAndEmit(srcPath, destDirName);        
    }
867642
protected final void parse(List<String> args) {
    Pattern eqSeparatedOpt = Pattern.compile("(--[^=]+)=(.+)");

    int idx = 0;
    for (idx = 0; idx < args.size(); idx++) {
      String arg = args.get(idx);
      String value = null;

      Matcher m = eqSeparatedOpt.matcher(arg);
      if (m.matches()) {
        arg = m.group(1);
        value = m.group(2);
      }

      // Look for options with a value.
      String name = findCliOption(arg, opts);
      if (name != null) {
        if (value == null) {
          if (idx == args.size() - 1) {
            throw new IllegalArgumentException(
                String.format("Missing argument for option '%s'.", arg));
          }
          idx++;
          value = args.get(idx);
        }
        if (!handle(name, value)) {
          break;
        }
        continue;
      }

      // Look for a switch.
      name = findCliOption(arg, switches);
      if (name != null) {
        if (!handle(name, null)) {
          break;
        }
        continue;
      }

      if (!handleUnknown(arg)) {
        break;
      }
    }

    if (idx < args.size()) {
      idx++;
    }
    handleExtraArgs(args.subList(idx, args.size()));
  }
977644
protected String getArguments(Object[] args) {

        if (args == null || args.length == 0) {
            return "";
        }

        StringBuilder sb = new StringBuilder();

        if (args.length == 1) {
            Object arg = args[0];
            String param = getSingleArgParameterAsString(arg);
            String displayParam = getSingleArgDisplayParameter(param);
            if (arg instanceof String) {
                sb.append("\"");
                sb.append(displayParam);
                sb.append("\"");
            } else {
                sb.append(displayParam);
            }
        } else {
            for (int i = 0; i < args.length; i++) {
                Object arg = args[i];
                boolean lastArg = i == args.length - 1;
                String param = getParameterAsString(arg);
                String displayParam = getDisplayParameter(param);
                if (arg instanceof String) {
                    sb.append("\"");
                    sb.append(displayParam);
                    sb.append("\"");
                } else {
                    sb.append(displayParam);
                }

                if (!lastArg) {
                    sb.append(",");
                }
            }
        }

        return sb.toString();
    }
33666
private CommandLine parseArgs(String[] args) throws ParseException {
        final CommandLineParser parser = new DefaultParser();
        final Options options = createCommandLineOptions();
        return parser.parse(options, args);
    }
1125444
public List<String> parse(String[] args) {    // merge args & defaults
        List<String> extras = new ArrayList<>();
        List<String> filteredArgs = filterMonadics(args);          // detect and fill mons
        for (int i = 0; i < filteredArgs.size(); i++) {
            String key = filteredArgs.get(i);
            if (key.equalsIgnoreCase("-h") || key.equalsIgnoreCase("-help")) {
                System.out.println(usage);
                System.exit(0);
            }
            
            if (parameters.containsKey(key)) {
                Parameter param = parameters.get(key);
                param.value = filteredArgs.get(i+1);
                switch(param.paramType) {
                    case INTEGER:
                        try {
                            Integer.parseInt(param.value);
                        } catch (Exception ex) {
                            System.err.println("Invalid parameter " + param.name + ' ' + param.value);
                            System.err.println(usage);
                            System.exit(1);
                        }
                        break;

                    case FLOAT:
                        try {
                            Double.parseDouble(param.value);
                        } catch (Exception ex) {
                            System.err.println("Invalid parameter " + param.name + ' ' + param.value);
                            System.err.println(usage);
                            System.exit(1);
                        }
                        break;
                        
                    default:
                    	// Just to remove unmatched case warning
                }
                i++;
            } else {
                extras.add(key);
            }
        }

        for(String key : parameters.keySet()) {
            Parameter param = parameters.get(key);
            if (param.mandatory && param.value == null) {
                System.err.println("Missing mandatory parameter: " + key);
                System.err.println(usage);
                System.exit(1);
            }
        }

        return extras;   // parsed + defaults
    }
1022977
protected final void args(Object... args) {
        if (args == null) args = NO_ARGS;
        this.args = args;
        retry();
    }
757122
void traverse(String[] args) {
        try {
            args = CommandLine.parse(args); // Detect @file and load it as a command line.
        } catch (java.io.IOException e) {
            throw new IllegalArgumentException("Problem reading @"+e.getMessage());
        }
        ArgumentIterator argIter = new ArgumentIterator(Arrays.asList(args));

        nextArg:
        while (argIter.hasNext()) {

            String arg = argIter.next();

            if (arg.startsWith("-")) {
                for (Option opt : Option.values()) {
                    if (opt.processCurrent(argIter, this))
                        continue nextArg;
                }

                javacArg(arg);

                // Does this javac argument take an argument? If so, don't
                // let it pass on to sjavac as a source root directory.
                for (com.sun.tools.javac.main.Option javacOpt : com.sun.tools.javac.main.Option.values()) {
                    if (javacOpt.matches(arg)) {
                        boolean takesArgument = javacOpt.hasArg();
                        boolean separateToken = !arg.contains(":") && !arg.contains("=");
                        if (takesArgument && separateToken)
                            javacArg(argIter.next());
                    }
                }
            } else {
                sourceRoots(Arrays.asList(Paths.get(arg)));
            }
        }
    }
1080257
public <A extends BaseArgument> ArgumentParser add(A arg) {
        if (arg instanceof BaseOption) {
            return add((BaseOption) arg);
        }

        // No arguments can be added after a sub-command-set.
        if (arguments.size() > 0 && arguments.get(arguments.size() - 1) instanceof SubCommandSet) {
            throw new IllegalArgumentException("No arguments can be added after a sub-command set");
        }

        arguments.add(arg);
        return this;
    }
442312
function parse(args) {
  const cliArgs = [];
  const nodeArgs = [];

  for (const arg of args) {
    if (NODE_FLAGS.test(arg)) {
      nodeArgs.push(arg);
    } else {
      cliArgs.push(arg);
    }
  }

  return {
    cliArgs,
    nodeArgs
  };
}
1182446
public void parseArgument(Collection<String> args) throws CmdLineException {
        parseArgument(args.toArray(new String[args.size()]));
    }
257563
public CommandLine parseArgs(final String[] args) throws CLIToolOptionsException {
        final CommandLine line = super.parseArgs(args);
        if (args.length > 0 && !args[0].startsWith("-")) {
            try {
                action = Actions.valueOf(args[0]);
            } catch (IllegalArgumentException e) {
                throw new CLIToolOptionsException(
                        "Invalid action: " + args[0] + ", must be one of: " + Arrays.toString(
                                Actions.values()
                        )
                );
            }
        }
        if (line.hasOption("h")) {
            help();
            exit(1);
        }
        return line;
    }