<p>parse.</p>

@param args a {@link java.lang.String} object.
@return an array of {@link java.lang.String} objects.
@throws com.greenpepper.util.cli.ParseException if any.
424348
public String[] parse( String... args ) throws ParseException
    {
        parser.parse( this, args );
        callStubs();
        return getArguments();
    }
1191532
public static HashMap<String,String> parse(String args){
		
		HashMap<String,String> map = new HashMap<>();
		
		if (args != null){
			String[] split = args.split(";");
			for (String nameValuePair : split) {
				String[] nameValue = nameValuePair.split("=");
				if (nameValue.length == 2){
					map.put(nameValue[0].toLowerCase(), nameValue[1]);
				}
			}
		}
		
		return map;
	}
205544
void parseCmdLine(String[] args) {
    JCommander parser = new JCommander(this, args);
    parser.setProgramName("GA4GHPicardRunner");
    LOG.info("Cmd line parsed");
  }
541221
private static CommandLine parseArgs(String[] args) throws ParseException {
    Options options = new Options();

    // Cluster
    Option o = new Option("c", "cluster", true,
        "cluster for which jobs are processed");
    o.setArgName("cluster");
    o.setRequired(true);
    options.addOption(o);

    // Input
    o = new Option("o", "output", true,
        "output directory in hdfs. This is where the index files are written.");
    o.setArgName("output-path");
    o.setRequired(true);
    options.addOption(o);

    // Input
    o = new Option("i", "input", true,
        "input directory in hdfs. Default is mapred.job.tracker.history.completed.location.");
    o.setArgName("input-path");
    o.setRequired(false);
    options.addOption(o);

    // Batch
    o = new Option("b", "batchSize", true,
        "The number of files to process in one batch. Default "
            + DEFAULT_BATCH_SIZE);
    o.setArgName("batch-size");
    o.setRequired(false);
    options.addOption(o);

    // raw file size limit
    o = new Option("s", "rawFileSize", true,
        "The max size of file that can be loaded into raw table. Default "
            + DEFAULT_RAW_FILE_SIZE_LIMIT);
    o.setArgName("rawfile-size");
    o.setRequired(false);
    options.addOption(o);

    // Force
    o = new Option("f", "forceAllFiles", false,
        "Force all files in a directory to be processed, no matter the previous processingRecord. Default: false. Usefull for batch loads.");
    o.setRequired(false);
    options.addOption(o);

    // Debugging
    options.addOption("d", "debug", false, "switch on DEBUG log level");

    CommandLineParser parser = new PosixParser();
    CommandLine commandLine = null;
    try {
      commandLine = parser.parse(options, args);
    } catch (Exception e) {
      System.err.println("ERROR: " + e.getMessage() + "\n");
      HelpFormatter formatter = new HelpFormatter();
      formatter.printHelp(NAME + " ", options, true);
      System.exit(-1);
    }

    // Set debug level right away
    if (commandLine.hasOption("d")) {
      Logger log = Logger.getLogger(JobFileRawLoader.class);
      log.setLevel(Level.DEBUG);
    }

    return commandLine;
  }
272529
public String[] parse(@NonNull String[] args) {
      List<String> filtered = new ArrayList<>();
      List<String> cleanedArgs = new ArrayList<>();

      //Pass through the args once to do a clean up will make the next round easier to parser.
      for (String c : args) {
         if (c.endsWith(KEY_VALUE_SEPARATOR) && isOptionName(c)) {
            //If it is ends with a key/value separator and is an option
            //lets separate them into two tokens.
            cleanedArgs.add(c.substring(0, c.length() - 1));
            cleanedArgs.add(KEY_VALUE_SEPARATOR);
         } else if (c.contains(KEY_VALUE_SEPARATOR) && isOptionName(c)) {
            //If it contains a key/value separator, but doesn't end in one and is an option
            //then we have a key value pair that will split into three tokens [key, =, value]
            int index = c.lastIndexOf(KEY_VALUE_SEPARATOR);
            cleanedArgs.add(c.substring(0, index));
            cleanedArgs.add(KEY_VALUE_SEPARATOR);
            cleanedArgs.add(c.substring(index + KEY_VALUE_SEPARATOR.length()));
         } else if (StringUtils.isNotNullOrBlank(c)) {
            //Anything else that isn't null or blank we keep as is
            cleanedArgs.add(c);
         }
      }

      for (int i = 0; i < cleanedArgs.size(); i++) {
         String current = cleanedArgs.get(i);

         //Check that the token isn't just a long or short argument marker.
         if (LONG.equals(current) || SHORT.equals(current)) {
            throw new CommandLineParserException(current, null);
         }

         if (current.startsWith(LONG)) {
            //We have a long form argument.
            String value = "true";
            String next = peek(cleanedArgs, i + 1);
            if (next.equalsIgnoreCase(KEY_VALUE_SEPARATOR)) {
               //If are peeked at value is our key value separator then lets set the value to what comes after.
               value = peek(cleanedArgs, i + 2);
               if (isOptionName(value)) {
                  //If the value is an option name, we have an error
                  throw new CommandLineParserException(current, null);
               }
               i += 2;
            } else if (!isOptionName(next)) {
               //If are peeked at value isn't our key value separator and isn't another option name, lets set the value to what comes after.
               i++;
               value = next;
            }
            setValue(current, value, filtered);
         } else if (current.startsWith(SHORT)) {
            //We have a short form argument.
            //Are we setting multiple "boolean" values?
            if (current.length() > 2) {
               //All of these will be set to true
               char[] opts = current.substring(1).toCharArray();
               for (char c : opts) {
                  setValue("-" + c, "true", filtered);
               }
            } else {
               String value = "true";
               String next = peek(cleanedArgs, i + 1);
               if (next.equalsIgnoreCase(KEY_VALUE_SEPARATOR)) {
                  //If are peeked at value is our key value separator then lets set the value to what comes after.
                  value = peek(cleanedArgs, i + 2);
                  if (isOptionName(value)) {
                     //If the value is an option name, we have an error
                     throw new CommandLineParserException(current, null);
                  }
                  i += 2;
               } else if (!isOptionName(next)) {
                  //If are peeked at value isn't our key value separator and isn't another option name, lets set the value to what comes after.
                  i++;
                  value = next;
               }
               setValue(current, value, filtered);
            }

         } else {
            filtered.add(current);
         }

      }

      //Check if the help was set, if a required argument was not set, and try to set the associated field on the owner object if one is set.
      optionSet.forEach(Unchecked.consumer(option -> {
         if (option.getName().equals("h") && Cast.<Boolean>as(option.getValue())) {
            showHelp();
            System.exit(0);
         } else if (option.isRequired() && !isSet(option.getName())) {
            System.err.println("ERROR: " + option.getName() + " is required, but was not set.");
            showHelp();
            System.exit(-1);
         }

         if (owner != null && option.getField() != null) {
            Reflect.onObject(owner).allowPrivilegedAccess().set(option.getField().getName(), option.getValue());
         }
      }));

      return filtered.toArray(new String[filtered.size()]);
   }
596515
@SuppressWarnings("unchecked") // marshall from apache commons cli
	private void parse() throws ParseException {
		_argValues = new HashMap<Argument, String>();
		_varargValues = new ArrayList<String>();
    List<String> argList = _commandLine.getArgList();
		
		int required = 0;
		boolean hasOptional = false;
		boolean hasVarargs = false;
		for(Argument argument : _arguments.getArguments()) {
			if(argument.isRequired()) {
				required++;
			} else {
				hasOptional = true;
			}
			if(argument.isVararg()) {
				hasVarargs = true;
			}
		}
		int allowed = hasOptional? required+1 : required;
		
		if(argList.size() < required) {
			throw new ParseException("Not enough arguments provided.  " + required + " required, but only " + argList.size() + " provided.");
		}
		
		if(!hasVarargs) {
			if(argList.size() > allowed) {
				throw new ParseException("Too many arguments provided.  Only " + allowed + " allowed, but " + argList.size() + " provided.");
			}
		}
		
		int index = 0;
		boolean finalArgEncountered = false;
		for(Argument argument : _arguments.getArguments()) {
			
			if(finalArgEncountered) throw new IllegalStateException("Illegal arguments defined.  No additional arguments may be defined after first optional or vararg argument.");
			
			if(argument.isRequired() && !argument.isVararg()) { // the normal case
				if(index <= argList.size()) {
					_argValues.put(argument, argList.get(index));
				} else {
					throw new IllegalStateException("not enough arguments"); // should not happen given above size check
				}
			}
			else { // it's the last argument, either it's optional or a vararg
				finalArgEncountered = true;
				
				if(argument.isVararg()) {
					_varargValues = argList.subList(Math.min(index, argList.size()), argList.size());
					
					if(argument.isRequired() && _varargValues.size() < 1) {
						throw new IllegalStateException("not enough arguments"); // should not happen given above size check
					}
				}
				else { // if it's a optional
					if(index < argList.size()) {
						_argValues.put(argument, argList.get(index));
					}
				}
			}
			index++;
		}
	}
1241810
@Override
    public void processArguments(String[] args) throws IOException {
        List<File> classFiles = new ArrayList<File>();
        List<File> jarFiles = new ArrayList<File>();
        String[] fileArgs = null;

        for (int i = 0; i < args.length; i++) {
            if (args[i].equalsIgnoreCase("--debug") || args[i].equals("-d")) {
                setDebug(true);
            } else if (args[i].equalsIgnoreCase("--config")) {
                // TODO: Handle config file parsing
                File configFile = new File(args[++i]);
                System.out.println("Config file not currently supported" + configFile);
            } else if (args[i].equalsIgnoreCase("--ffdc")) {
                addFfdc = true;
            } else if (args[i].equalsIgnoreCase("--static")) {
                injectStatic = true;
            } else if (args[i].equalsIgnoreCase("--liberty")) {
                defaultTraceType = TraceType.LIBERTY;
            } else if (args[i].equalsIgnoreCase("--tr")) {
                defaultTraceType = TraceType.TR;
            } else if (args[i].equalsIgnoreCase("--java-logging")) {
                defaultTraceType = TraceType.JAVA_LOGGING;
            } else {
                fileArgs = new String[args.length - i];
                System.arraycopy(args, i, fileArgs, 0, fileArgs.length);
                break;
            }
        }

        if (fileArgs == null || fileArgs.length == 0) {
            throw new IllegalArgumentException("No file specified");
        }

        // Add jar files, zip files, and class files to the appropriate collections
        for (int i = 0; i < fileArgs.length; i++) {
            File f = new File(fileArgs[i]);
            if (!f.exists()) {
                throw new IllegalArgumentException("File \"" + f + "\" does not exist");
            } else if (f.isDirectory()) {
                classFiles.addAll(getClassFiles(f, null));
                jarFiles.addAll(getJarFiles(f, null));
            } else if (f.getName().endsWith(".class")) {
                classFiles.add(f);
            } else if (f.getName().endsWith(".jar")) {
                jarFiles.add(f);
            } else if (f.getName().endsWith(".zip")) {
                jarFiles.add(f);
            } else {
                System.err.println(f + " is an unexpected file type; ignoring");
            }
        }

        setClassFiles(classFiles);
        setJarFiles(jarFiles);
    }
1163402
public static Array toArray(Argument arg) {
	ArrayImpl trg = new ArrayImpl();
	int[] keys = arg.intKeys();
	for (int i = 0; i < keys.length; i++) {
	    trg.setEL(keys[i], arg.get(keys[i], null));
	}
	return trg;
    }
1095105
public static String[] tokenize(String args) {

    // Split the args string on whitespace boundaries accounting for quoted
    // strings.
    args = args.trim();
    List<String> argList = new ArrayList<>();
    String arg = "";
    char activeQuote = 0;
    for (int ii = 0; ii < args.length(); ii++) {
      char ch = args.charAt(ii);
      if ((ch == '\'') || (ch == '"')) {
        arg += ch;
        ii++;
        while ((ii < args.length()) && (args.charAt(ii) != ch)) {
          arg += args.charAt(ii++);
        }
        arg += ch;
      } else if (Character.isWhitespace(ch)) {
        // System.out.printf ("adding argument '%s'%n", arg);
        argList.add(arg);
        arg = "";
        while ((ii < args.length()) && Character.isWhitespace(args.charAt(ii))) {
          ii++;
        }
        if (ii < args.length()) {
          // Encountered a non-whitespace character.
          // Back up to process it on the next loop iteration.
          ii--;
        }
      } else { // must be part of current argument
        arg += ch;
      }
    }
    if (!arg.equals("")) {
      argList.add(arg);
    }

    String[] argsArray = argList.toArray(new String[argList.size()]);
    return argsArray;
  }
88287
public static void main(String[] args) {
        try {
            javax.xml.parsers.SAXParserFactory fac = javax.xml.parsers.SAXParserFactory.newInstance();
            fac.setNamespaceAware(true);
            fac.setValidating(false);
            XMLReader parser = fac.newSAXParser().getXMLReader();
            parser.setContentHandler(new HtmlSerializer(System.out));
            parser.parse(args[0]);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
1001456
protected void parse (String arg, Argument argDesc)
        throws YarrgParseException
    {
        Parser<?> parser = parsers.get(argDesc.field);
        if (parser == null) {
            parser = _cmd._factory.createParser(argDesc.field);
            parsers.put(argDesc.field, parser);
        }
        try {
            parser.add(arg);
        } catch (RuntimeException e) {
            throw new YarrgParseException(_usage, e.getMessage(), e);
        }
    }
789042
@SuppressWarnings("checkstyle:regexp")
	public static void showCommandLineArguments(String[] args) {
		try (PrintStream os = getConsoleLogger()) {
			for (int i = 0; i < args.length; ++i) {
				os.println(i + ": " //$NON-NLS-1$
						+ args[i]);
			}
			os.flush();
		} catch (Throwable e) {
			e.printStackTrace();
		}
		getExiter().exit();
	}
1184315
@Override
    public T parse(String arg) throws ParseException {
        if (isNull(arg)) {
            if (nullable) {
                return null;
            } else {
                throw new ParseException(ParseError.INVALID_PARAM, "Parameter doesn't take 'null' values: " + getName());
            }
        }
        return parseNonNull(arg);
    }
1051043
public static void main(String[] args) throws ParseException {
		CliFrontend cli = new CliFrontend();
		int retCode = cli.parseParameters(args);
		System.exit(retCode);
	}
155357
public final void parseCLI(final String[] args) throws IOException,
      JDOMException {
    try {
      this.parsedArguments = this.argParser.parseArgs(args);
      System.err.println("CLI options: " + this.parsedArguments);
      if (args[0].equals("parse")) {
        annotate(System.in, System.out);
      } else if (args[0].equals("eval")) {
        eval();
      } else if (args[0].equals("train")) {
        train();
      } else if (args[0].equals("server")) {
        server();
      } else if (args[0].equals("client")) {
        client(System.in, System.out);
      }
    } catch (final ArgumentParserException e) {
      this.argParser.handleError(e);
      System.out.println("Run java -jar target/ixa-pipe-parse-" + this.version
          + ".jar" + " (parse|train|eval|server|client) -help for details");
      System.exit(1);
    }
  }
176675
public void runArgs(String[] args) {
        CommandLineParser clParser = new DefaultParser();
        CommandLine line;
        String host;
        String port;
        CMD cmd;
        String[] cmdArgs;
        final PrintStream CONSOLE = System.out;
        try {
            // parse the command line arguments
            line = clParser.parse(options, args);

            if (line.hasOption("output")){
                String location = line.getOptionValue("output");
                File output = new File(location);
                FileOutputStream fos;
                try {
                    fos = new FileOutputStream(output);
                } catch (FileNotFoundException e) {
                    e.printStackTrace();
                    throw new ParseException(String.format("Wrong -o option. args %s\n",Arrays.asList(args)));
                }
                PrintStream out = new PrintStream(fos);
                System.setOut(out);

            }
            if (line.getOptions().length==0 || line.hasOption("help")) {
                if ((line.getOptions().length > 2) || (line.getOptions().length==2 && !line.hasOption("output"))){
                    throw new ParseException(String.format("Wrong -help option. args %s\n", Arrays.asList(args)));
                }
                printUsage(System.out);
            }
            if (line.hasOption("server")) {
                String server = line.getOptionValue("server");
                try {
                    host = server.split(":")[0];
                    port = server.split(":")[1];
                }catch (Exception e){
                    throw new ParseException(String.format("Wrong -server option. args %s\n", Arrays.asList(args)));
                }
                ServiceDirectory.getServiceDirectoryConfig().setProperty(
                        DirectoryServiceRestfulClient.SD_API_SD_SERVER_FQDN_PROPERTY,
                        host);
                ServiceDirectory.getServiceDirectoryConfig().setProperty(
                        DirectoryServiceRestfulClient.SD_API_SD_SERVER_PORT_PROPERTY,
                        port);
            }

            if (line.hasOption("exec")) {
                String commandString = line.getOptionValue("exec");
                cmdArgs = parseCommand(commandString);
                try {
                    cmd = CMD.valueOf(cmdArgs[0]);
                } catch (IllegalArgumentException e) {
                    throw new ParseException(String.format("Unknown command [ %s ] \n", commandString));
                }
                if (cmd.sizeOfArgs + 1 != cmdArgs.length) {
                    throw new ParseException(
                            String.format("Wrong arguments number for command %s, required %s but %s \n",
                                    cmdArgs[0], cmd.sizeOfArgs, cmdArgs.length - 1));
                }
                switch (cmd) {
                    case getInstanceOf:
                        lookupInstance(cmdArgs);
                        break;
                    case getAllInstancesOf:
                        lookupInstances(cmdArgs);
                        break;
                    case getAllServices:
                        getAllServices();
                        break;
                    case registerService:
                        registerService(cmdArgs);
                        break;
                    default:
                        fail("command " + cmd + " is unsupported yet");
                        break;
                }

            }
        } catch (ParseException exp) {
            // oops, something went wrong
            exp.printStackTrace();
            try {
                TimeUnit.MILLISECONDS.sleep(100L);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            printUsage(System.err);
        }
        System.setOut(CONSOLE);
    }
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();
    }