Assembles the command line arguments for the invocation of JJDoc according
to the configuration.

@return A string array that represents the arguments to use for JJDoc.
965348
private String [] _generateArguments ()
  {
    final List <String> argsList = new ArrayList <> ();

    if (StringUtils.isNotEmpty (this.grammarEncoding))
    {
      argsList.add ("-GRAMMAR_ENCODING=" + this.grammarEncoding);
    }

    if (StringUtils.isNotEmpty (this.outputEncoding))
    {
      argsList.add ("-OUTPUT_ENCODING=" + this.outputEncoding);
    }

    if (this.text != null)
    {
      argsList.add ("-TEXT=" + this.text);
    }

    if (this.bnf != null)
    {
      argsList.add ("-BNF=" + this.bnf);
    }

    if (this.oneTable != null)
    {
      argsList.add ("-ONE_TABLE=" + this.oneTable);
    }

    if (this.outputFile != null)
    {
      argsList.add ("-OUTPUT_FILE=" + this.outputFile.getAbsolutePath ());
    }

    if (StringUtils.isNotEmpty (this.cssHref))
    {
      argsList.add ("-CSS=" + this.cssHref);
    }

    if (this.inputFile != null)
    {
      argsList.add (this.inputFile.getAbsolutePath ());
    }

    return argsList.toArray (new String [argsList.size ()]);
  }
778924
@SuppressWarnings({"checkstyle:cyclomaticcomplexity", "checkstyle:npathcomplexity"})
	public static String[] parseCommandLine(String[] args) {
		final CommandLineParser parser = new DefaultParser();
		try {
			final CommandLine cmd = parser.parse(getOptions(), args, false);

			boolean noLogo = false;
			boolean embedded = false;
			boolean userClasspath = false;
			int verbose = LoggerCreator.toInt(JanusConfig.VERBOSE_LEVEL_VALUE);

			final Iterator<Option> optIterator = cmd.iterator();
			while (optIterator.hasNext()) {
				final Option opt = optIterator.next();
				String optName = opt.getLongOpt();
				if (Strings.isNullOrEmpty(optName)) {
					optName = opt.getOpt();
				}
				switch (optName) {
				case CLI_OPTION_HELP_LONG:
					showHelp(true);
					return null;
				case CLI_OPTION_VERSION:
					showVersion(true);
					return null;
				case CLI_OPTION_SHOWDEFAULTS_LONG:
					showDefaults();
					return null;
				case CLI_OPTION_SHOWCLASSPATH:
					setDefaultClasspath(userClasspath);
					showClasspath();
					return null;
				case CLI_OPTION_SHOWCLIARGUMENTS_LONG:
					showCommandLineArguments(args);
					return null;
				case CLI_OPTION_FILE_LONG:
					final String rawFilename = opt.getValue();
					if (rawFilename == null || "".equals(rawFilename)) { //$NON-NLS-1$
						showHelp(true);
					}
					final File file = new File(rawFilename);
					if (!file.canRead()) {
						showError(MessageFormat.format(Messages.Boot_0,
								rawFilename), null);
						return null;
					}
					setPropertiesFrom(file);
					break;
				case CLI_OPTION_CLASSPATH_LONG:
					userClasspath = true;
					addToSystemClasspath(opt.getValue());
					break;
				case CLI_OPTION_OFFLINE_LONG:
					setOffline(true);
					break;
				case CLI_OPTION_RANDOMID_LONG:
					setRandomContextUUID();
					break;
				case CLI_OPTION_BOOTID_LONG:
					setBootAgentTypeContextUUID();
					break;
				case CLI_OPTION_WORLDID_LONG:
					setDefaultContextUUID();
					break;
				case CLI_OPTION_DEFINE_LONG:
					final String name = opt.getValue(0);
					if (!Strings.isNullOrEmpty(name)) {
						setProperty(name, Strings.emptyToNull(opt.getValue(1)));
					}
					break;
				case CLI_OPTION_LOG_LONG:
					verbose = Math.max(LoggerCreator.toInt(opt.getValue()), 0);
					break;
				case CLI_OPTION_QUIET_LONG:
					if (verbose > 0) {
						--verbose;
					}
					break;
				case CLI_OPTION_VERBOSE_LONG:
					++verbose;
					break;
				case CLI_OPTION_NOLOGO_LONG:
					noLogo = true;
					break;
				case CLI_OPTION_EMBEDDED_LONG:
					embedded = true;
					break;
				default:
				}
			}

			setDefaultClasspath(userClasspath);

			// Show the help when there is no argument.
			if (cmd.getArgs().length == 0) {
				showHelp(true);
				return null;
			}

			// Change the verbosity
			setVerboseLevel(verbose);
			// Do nothing at exit
			if (embedded) {
				setExiter(() -> {
					ExecutorService.neverReturn();
				});
			}
			// Show the Janus logo?
			if (noLogo || verbose == 0) {
				setProperty(JanusConfig.JANUS_LOGO_SHOW_NAME, Boolean.FALSE.toString());
			}
			return cmd.getArgs();
		} catch (IOException | ParseException e) {
			showError(e.getLocalizedMessage(), e);
			// Event if showError never returns, add the return statement for
			// avoiding compilation error.
			return null;
		}
	}
177366
public static String[] processOptions(String args[])
    {
        String usageError;
        goodUsage: for (int i = 0; ; ++i) {
            if (i == args.length) {
                return new String[0];
            }
            String arg = args[i];
            if (!arg.startsWith("-")) {
                processStdin = false;
                fileList.add(arg);
                mainModule = arg;
                String[] result = new String[args.length - i - 1];
                System.arraycopy(args, i+1, result, 0, args.length - i - 1);
                return result;
            }
            if (arg.equals("-version")) {
                if (++i == args.length) {
                    usageError = arg;
                    break goodUsage;
                }
                int version;
                try {
                    version = Integer.parseInt(args[i]);
                } catch (NumberFormatException ex) {
                    usageError = args[i];
                    break goodUsage;
                }
                if (!Context.isValidLanguageVersion(version)) {
                    usageError = args[i];
                    break goodUsage;
                }
                shellContextFactory.setLanguageVersion(version);
                continue;
            }
            if (arg.equals("-opt") || arg.equals("-O")) {
                if (++i == args.length) {
                    usageError = arg;
                    break goodUsage;
                }
                int opt;
                try {
                    opt = Integer.parseInt(args[i]);
                } catch (NumberFormatException ex) {
                    usageError = args[i];
                    break goodUsage;
                }
                if (opt == -2) {
                    // Compatibility with Cocoon Rhino fork
                    opt = -1;
                } else if (!Context.isValidOptimizationLevel(opt)) {
                    usageError = args[i];
                    break goodUsage;
                }
                shellContextFactory.setOptimizationLevel(opt);
                continue;
            }
            if (arg.equals("-encoding")) {
                if (++i == args.length) {
                    usageError = arg;
                    break goodUsage;
                }
                String enc = args[i];
                shellContextFactory.setCharacterEncoding(enc);
                continue;
            }
            if (arg.equals("-strict")) {
                shellContextFactory.setStrictMode(true);
                shellContextFactory.setAllowReservedKeywords(false);
                errorReporter.setIsReportingWarnings(true);
                continue;
            }
            if (arg.equals("-fatal-warnings")) {
                shellContextFactory.setWarningAsError(true);
                continue;
            }
            if (arg.equals("-e")) {
                processStdin = false;
                if (++i == args.length) {
                    usageError = arg;
                    break goodUsage;
                }
                if (!global.initialized) {
                    global.init(shellContextFactory);
                }
                IProxy iproxy = new IProxy(IProxy.EVAL_INLINE_SCRIPT);
                iproxy.scriptText = args[i];
                shellContextFactory.call(iproxy);
                continue;
            }
            if (arg.equals("-require")) {
                useRequire = true;
                continue;
            }
            if (arg.equals("-sandbox")) {
                sandboxed = true;
                useRequire = true;
                continue;
            }
            if (arg.equals("-modules")) {
                if (++i == args.length) {
                    usageError = arg;
                    break goodUsage;
                }
                if (modulePath == null) {
                    modulePath = new ArrayList<String>();
                }
                modulePath.add(args[i]);
                useRequire = true;
                continue;
            }
            if (arg.equals("-w")) {
                errorReporter.setIsReportingWarnings(true);
                continue;
            }
            if (arg.equals("-f")) {
                processStdin = false;
                if (++i == args.length) {
                    usageError = arg;
                    break goodUsage;
                }
                if (args[i].equals("-")) {
                    fileList.add(null);
                } else {
                    fileList.add(args[i]);
                    mainModule = args[i];
                }
                continue;
            }
            if (arg.equals("-sealedlib")) {
                global.setSealedStdLib(true);
                continue;
            }
            if (arg.equals("-debug")) {
                shellContextFactory.setGeneratingDebug(true);
                continue;
            }
            if (arg.equals("-?") ||
                arg.equals("-help")) {
                // print usage message
                global.getOut().println(
                    ToolErrorReporter.getMessage("msg.shell.usage", Main.class.getName()));
                exitCode = 1;
                return null;
            }
            usageError = arg;
            break goodUsage;
        }
        // print error and usage message
        global.getOut().println(
            ToolErrorReporter.getMessage("msg.shell.invalid", usageError));
        global.getOut().println(
            ToolErrorReporter.getMessage("msg.shell.usage", Main.class.getName()));
        exitCode = 1;
        return null;
    }
680928
public static Map<String, String> readCommandLineOpts() {
    return org.apache.heron.api.utils.Utils.readCommandLineOpts();
  }
1106728
protected function getMappedArguments()
    {
        $requiredArgs = array(
            'client'       => 'Prefix',
            'tool-title'   => 'Tool title',
            'transparent'  => '(1 or 0)',
            'rotatable'    => '(1 or 0)',
            'movable'      => '(1 or 0)',
            'adjustable-x' => '(1 or 0)',
            'adjustable-y' => '(1 or 0)',
        );
        $argHelp = "<p>Required arguments are:</p><ul>";
        foreach ($requiredArgs as $key => $value) {
            $argHelp .= '<li>' . $key . ': ' . $value . '</li>';
        }
        $argHelp .= '</ul>';

        foreach ($requiredArgs as $key => $value) {
            // !string '0' is a valid entry!
            if (!isset($_POST[$key]) || $_POST[$key] === '') {
                throw new \Exception($argHelp);
                break;
            }
            // trim all, cast 0|1 to bool
            $_POST[$key] = trim($_POST[$key]);
            if (in_array($_POST[$key], array('0', '1'))) {
                $_POST[$key] = (bool)$_POST[$key];
            }
        }

        $_POST['client']           = strtoupper($_POST['client']);
        $_POST['tool-base']        = StringUtils::removeSpecChars($_POST['tool-title']);
        $_POST['tool-fn']          = StringUtils::camelize($_POST['tool-base']);
        $_POST['tool-obj']         = ucfirst($_POST['tool-fn']);
        $_POST['tool-id']          = strtolower($_POST['client']) . $_POST['tool-obj'];
        $_POST['is-transparent']   = json_encode($_POST['transparent']);
        $_POST['is-rotatable-tl']  = json_encode($_POST['rotatable']); // default position of rotator

                                        // only visible when not adjustable
        $_POST['is-rotatable-tr']  = json_encode($_POST['rotatable'] && (!$_POST['adjustable-x'] && !$_POST['adjustable-y']));
        $_POST['is-rotatable-br']  = json_encode($_POST['rotatable'] && (!$_POST['adjustable-x'] && !$_POST['adjustable-y']));

        $_POST['is-rotatable-bl']  = json_encode($_POST['rotatable']); // also default position of rotator

        // alternative positions, need to be configured manually
        $_POST['is-rotatable-t']  = json_encode(false);
        $_POST['is-rotatable-r']  = json_encode(false);
        $_POST['is-rotatable-b']  = json_encode(false);
        $_POST['is-rotatable-l']  = json_encode(false);

        $_POST['is-movable']       = json_encode($_POST['movable']);
        $_POST['is-adjustable-x']  = json_encode($_POST['adjustable-x']);
        $_POST['is-adjustable-y']  = json_encode($_POST['adjustable-y']);
        $_POST['is-adjustable-xy'] = json_encode($_POST['adjustable-x'] && $_POST['adjustable-y']);

        unset($_POST['transparent']);
        unset($_POST['rotatable']);
        unset($_POST['movable']);
        unset($_POST['adjustable-x']);
        unset($_POST['adjustable-y']);

        return $_POST;
    }
1264404
protected RunArguments resolveJvmArguments() {
		StringBuilder stringBuilder = new StringBuilder();
		if (this.systemPropertyVariables != null) {
			stringBuilder.append(this.systemPropertyVariables.entrySet().stream()
					.map((e) -> SystemPropertyFormatter.format(e.getKey(), e.getValue()))
					.collect(Collectors.joining(" ")));
		}
		if (this.jvmArguments != null) {
			stringBuilder.append(" ").append(this.jvmArguments);
		}
		return new RunArguments(stringBuilder.toString());
	}
530631
public String[] getCommandLine() {
        String[] argsAry = argsString != null ? split(argsString) : EMPTY_ARRAY;
        List<String> argsList = new ArrayList<String>();

        int startIndex = 0;

        for (CommandOption opt : optionsList) {
            String argName = opt.getName();
            String argValueString = opt.getValue();

            argsList.add((argName.length() == 1 ? "-" : "--") + argName);

            if (argValueString != null) {
                argsList.add(quote(argValueString));
            }
        }

        String[] resAry = new String[argsAry.length + argsList.size()];

        for (String argString : argsList) {
            resAry[startIndex++] = argString;
        }

        // vsRes = new String[args.length + m_vArguments.size()];
        System.arraycopy(argsAry, 0, resAry, startIndex, argsAry.length);

        return resAry;
    }
201221
private void getJavaSource() {
		String[] resourceFiles = new String[getConfigurationFiles().length + 1];
		resourceFiles[0] = getSourceFileName();
		for (int i = 0; i < getConfigurationFiles().length; i++) {
			resourceFiles[i + 1] = getConfigurationFiles()[i];
		}

		GetResourceRequest request = new GetResourceRequest(resourceFiles);
		GwtCommand command = new GwtCommand(GetResourceRequest.COMMAND);
		command.setCommandRequest(request);
		GwtCommandDispatcher.getInstance().execute(command, new AbstractCommandCallback<GetResourceResponse>() {

			public void execute(GetResourceResponse response) {
				if (response.getResources() == null) {
					return;
				}
				showFiles(response.getResources());
			}
		});
	}
513150
public String[] command() throws IOException{
        List<String> cmd = new ArrayList<String>();

        String executable = javaHome.getCanonicalPath()+FileUtil.SEPARATOR+"bin"+FileUtil.SEPARATOR+"java";
        if(OS.get().isWindows())
            executable += ".exe";
        cmd.add(executable);

        String path = toString(workingDir, prependBootClasspath);
        if(path.length()>0)
            cmd.add("-Xbootclasspath/p:"+path);

        path = toString(workingDir, bootClasspath);
        if(path.length()>0)
            cmd.add("-Xbootclasspath:"+path);

        path = toString(workingDir, appendBootClasspath);
        if(path.length()>0)
            cmd.add("-Xbootclasspath/a:"+path);

        path = toString(workingDir, classpath);
        if(path.length()>0){
            cmd.add("-classpath");
            cmd.add(path);
        }

        path = toString(workingDir, extDirs);
        if(path.length()>0)
            cmd.add("-Djava.ext.dirs="+path);

        path = toString(workingDir, endorsedDirs);
        if(path.length()>0)
            cmd.add("-Djava.endorsed.dirs="+path);

        path = toString(workingDir, libraryPath);
        if(path.length()>0)
            cmd.add("-Djava.library.path="+path);

        for(Map.Entry<String, String> prop: systemProperties.entrySet()){
            if(prop.getValue()==null)
                cmd.add("-D"+prop.getKey());
            else
                cmd.add("-D"+prop.getKey()+"="+prop.getValue());
        }

        if(initialHeap!=null)
            cmd.add("-Xms"+initialHeap);
        if(maxHeap!=null)
            cmd.add("-Xmx"+maxHeap);
        if(vmType!=null)
            cmd.add(vmType);
        if(debugPort!=-1){
            cmd.add("-Xdebug");
            cmd.add("-Xnoagent");
            cmd.add("-Xrunjdwp:transport=dt_socket,server=y,suspend="+(debugSuspend?'y':'n')+",address="+debugPort);
        }
        cmd.addAll(jvmArgs);
        if(mainClass!=null){
            cmd.add(mainClass);
            cmd.addAll(args);
        }

        return cmd.toArray(new String[cmd.size()]);
    }
1318439
public List<String> getArgs() {
        List<String> args = new ArrayList<String>();
        getArgs(this.expression, args);

        return args;
    }
736557
public String getCmdLineArg() {
        StringBuilder builder = new StringBuilder("  --server-groups=");
        boolean foundSelected = false;
        for (JCheckBox serverGroup : serverGroups) {
            if (serverGroup.isSelected()) {
                foundSelected = true;
                builder.append(serverGroup.getText());
                builder.append(",");
            }
        }
        builder.deleteCharAt(builder.length() - 1); // remove trailing comma

        if (!foundSelected) return "";
        return builder.toString();
    }
832508
protected Commandline getCommandline() {
        Commandline cmdl = new Commandline();
        if (configFile != null) {
            cmdl.createArgument().setValue("--config");
            cmdl.createArgument().setFile(configFile);
        }
        if (debug) {
            cmdl.createArgument().setValue("--debug");
        }
        return cmdl;
    }
1311308
private StringBuffer getArgsString(Object[] args) {
        StringBuffer buffer = new StringBuffer();
        String prefix = "args ";
        for (int i = 0; i < args.length; i++) {
            if (args.length > 1) {
                buffer.append(prefix + (i + 1));
            }
            buffer.append("\r\t");
            buffer.append(getResultString(args[i]));
            buffer.append("\n");
        }
        return buffer;
    }
441657
public static String getJvmStartupOptions() {
		try {
			final RuntimeMXBean bean = ManagementFactory.getRuntimeMXBean();
			final StringBuilder bld = new StringBuilder();
			
			for (String s : bean.getInputArguments()) {
				bld.append(s).append(' ');
			}

			return bld.toString();
		}
		catch (Throwable t) {
			return UNKNOWN;
		}
	}
61955
private String getArgumentDescription(
            final Map<String, NamedArgumentDefinition> allActualArguments,
            final Collection<CommandLinePluginDescriptor<?>> pluginDescriptors) {
        final StringBuilder sb = new StringBuilder();
        if (!getDocString().isEmpty()) {
            sb.append(getDocString());
            sb.append("  ");
        }
        if (isCollection()) {
            if (isOptional()) {
                sb.append("This argument may be specified 0 or more times. ");
            } else {
                sb.append("This argument must be specified at least once. ");
            }
        }
        if (isOptional()) {
            sb.append("Default value: ");
            sb.append(getDefaultValueAsString());
            sb.append(". ");
        } else {
            sb.append("Required. ");
        }

        // if this argument definition is a string field claimed by a plugin descriptor (i.e.,
        // it holds the names of plugins specified by the user on the command line, such as read filter names),
        // then we need to delegate to the plugin descriptor to generate the list of allowed values
        if (!usageForPluginDescriptorArgument(sb, pluginDescriptors)) {
            // If the argument wasn't claimed by any descriptor, treat it as a normal argument
            sb.append(getOptionsAsDisplayString());
        }

        if (!getMutexTargetList().isEmpty()) {
            sb.append(" Cannot be used in conjunction with argument(s)");
            for (final String argument : getMutexTargetList()) {
                final NamedArgumentDefinition mutexArgumentDefinition = allActualArguments.get(argument);
                sb.append(" ").append(mutexArgumentDefinition.getUnderlyingField().getName());
                if (!mutexArgumentDefinition.getShortName().isEmpty()) {
                    sb.append(" (").append(mutexArgumentDefinition.getShortName()).append(")");
                }
            }
        }
        return sb.toString();
    }
630360
public List<CliArgumentContainer> getArguments(CliModeObject mode) {

    List<CliArgumentContainer> result = new ArrayList<>();
    for (CliArgumentContainer argumentContainer : this.arguments) {
      String argumentModeId = argumentContainer.getArgument().mode();
      CliModeObject argumentMode = getMode(argumentModeId);
      if ((argumentMode == mode) || argumentMode.isAncestorOf(mode)) {
        result.add(argumentContainer);
      }
    }
    return result;
  }
691343
private static CommandLine parseCommandLine(final String[] vsArgs) {
        try {
            Group opts = configureCommandLine();
            // configure a HelpFormatter
            HelpFormatter hf = new HelpFormatter();

            // configure a parser
            Parser p = new Parser();
            p.setGroup(opts);
            p.setHelpFormatter(hf);
            // p.setHelpTrigger("--help");
            return p.parse(vsArgs);
        } catch (OptionException oe) {
            printUsage(oe);
        } catch (Exception e) {
            e.printStackTrace();
            // Should never happen...
        }
        return null;
    }