If you need to add an option that affects processing of input files,
 you can use this method.
762246
def add_input_option(option_name, *args)
      (@input_options ||= []).push(option_name)
      args.each { |ea| @input_options.push(Shellwords.escape(ea.to_s)) }

      # Support call chaining:
      self
    end
730003
private void processField(Field field) {
    OptionArgument optAnnotation = field.getAnnotation(OptionArgument.class);
    if (optAnnotation != null) {
      processOptionField(field, optAnnotation.value(), optAnnotation.shortKey());
    } else {
      CommandArgument cmdAnnotation = field.getAnnotation(CommandArgument.class);
      if (cmdAnnotation != null) {
        processCommandField(field, cmdAnnotation.value(), null);
      } else {
        ShellArgument shellAnnotation = field.getAnnotation(ShellArgument.class);
        if (shellAnnotation != null) {
          processCommandField(field, shellAnnotation.value(), shellAnnotation.prompt());
        }
      }
    }
  }
54182
def fix_config(self, options):
        
        opt = "setup"
        if opt not in options:
            options[opt] = conversion.PassThrough()
        if opt not in self.help:
            self.help[opt] = "The conversion to apply to the input data (Conversion)."

        return super(Convert, self).fix_config(options)
202712
protected function processOptions($filename = null)
    {
        // output must be first option after operation
        if ($filename!==null) {
            $this->addArg('output', $filename, true);
        }
        foreach ($this->_options as $option) {
            if (is_array($option)) {
                $this->addArg($option[0], $option[1], $option[2]);
            } else {
                $this->addArg($option);
            }
        }
    }
525071
private Input processRegularFileInput(String input) throws IOException {
    File inputFile = new File(input);
    if (!inputFile.exists()) {
      throw new IOException("Input does not exist: " + input);
    }
    if (pipeFiles) {
      SamReader samReader = SamReaderFactory.makeDefault().open(inputFile);
      return new Input(input, STDIN_FILE_NAME, 
          new SamReaderToSAMFilePump(samReader)); 
    } else {
      return new Input(input, input, null);
    }
  }
520286
protected function processInputFiles()
    {
        $passwords = array();
        foreach ($this->_files as $handle => $file) {
            $this->addArg($handle.'=',$file['name']);
            if ($file['password']!==null) {
                $passwords[$handle] = $file['password'];
            }
        }
        if ($passwords!==array()) {
            $this->addArg('input_pw');
            foreach ($passwords as $handle => $password) {
                $this->addArg($handle.'=', $password);
            }
        }
    }
243067
@SuppressWarnings("static-access")
    private void addStandardOptions(final Options options) {
        final Option help = new Option(ARGUMENT.HELP_SHORT, ARGUMENT.HELP, false,
                "Print this message.");

        final Option advancedHelp = Option.builder().longOpt(ARGUMENT.ADVANCED_HELP)
                .desc("Print the advanced help message.").build();

        final Option version = new Option(ARGUMENT.VERSION_SHORT, ARGUMENT.VERSION,
                false, "Print the version information.");

        final Option noUpdate = new Option(ARGUMENT.DISABLE_AUTO_UPDATE_SHORT, ARGUMENT.DISABLE_AUTO_UPDATE,
                false, "Disables the automatic updating of the CPE data.");

        final Option projectName = Option.builder().hasArg().argName("name").longOpt(ARGUMENT.PROJECT)
                .desc("The name of the project being scanned.")
                .build();

        final Option path = Option.builder(ARGUMENT.SCAN_SHORT).argName("path").hasArg().longOpt(ARGUMENT.SCAN)
                .desc("The path to scan - this option can be specified multiple times. Ant style"
                        + " paths are supported (e.g. path/**/*.jar).")
                .build();

        final Option excludes = Option.builder().argName("pattern").hasArg().longOpt(ARGUMENT.EXCLUDE)
                .desc("Specify an exclusion pattern. This option can be specified multiple times"
                        + " and it accepts Ant style exclusions.")
                .build();

        final Option props = Option.builder(ARGUMENT.PROP_SHORT).argName("file").hasArg().longOpt(ARGUMENT.PROP)
                .desc("A property file to load.")
                .build();

        final Option out = Option.builder(ARGUMENT.OUT_SHORT).argName("path").hasArg().longOpt(ARGUMENT.OUT)
                .desc("The folder to write reports to. This defaults to the current directory. "
                        + "It is possible to set this to a specific file name if the format argument is not set to ALL.")
                .build();

        final Option outputFormat = Option.builder(ARGUMENT.OUTPUT_FORMAT_SHORT).argName("format").hasArg().longOpt(ARGUMENT.OUTPUT_FORMAT)
                .desc("The output format to write to (" + SUPPORTED_FORMATS + "). The default is HTML.")
                .build();

        final Option verboseLog = Option.builder(ARGUMENT.VERBOSE_LOG_SHORT).argName("file").hasArg().longOpt(ARGUMENT.VERBOSE_LOG)
                .desc("The file path to write verbose logging information.")
                .build();

        final Option symLinkDepth = Option.builder().argName("depth").hasArg().longOpt(ARGUMENT.SYM_LINK_DEPTH)
                .desc("Sets how deep nested symbolic links will be followed; 0 indicates symbolic links will not be followed.")
                .build();

        final Option suppressionFile = Option.builder().argName("file").hasArgs().longOpt(ARGUMENT.SUPPRESSION_FILES)
                .desc("The file path to the suppression XML file. This can be specified more then once to utilize multiple "
                        + "suppression files")
                .build();

        final Option hintsFile = Option.builder().argName("file").hasArg().longOpt(ARGUMENT.HINTS_FILE)
                .desc("The file path to the hints XML file.")
                .build();

        final Option cveValidForHours = Option.builder().argName("hours").hasArg().longOpt(ARGUMENT.CVE_VALID_FOR_HOURS)
                .desc("The number of hours to wait before checking for new updates from the NVD.")
                .build();

        final Option experimentalEnabled = Option.builder().longOpt(ARGUMENT.EXPERIMENTAL)
                .desc("Enables the experimental analyzers.")
                .build();

        final Option retiredEnabled = Option.builder().longOpt(ARGUMENT.RETIRED)
                .desc("Enables the retired analyzers.")
                .build();

        final Option failOnCVSS = Option.builder().argName("score").hasArg().longOpt(ARGUMENT.FAIL_ON_CVSS)
                .desc("Specifies if the build should be failed if a CVSS score above a specified level is identified. "
                        + "The default is 11; since the CVSS scores are 0-10, by default the build will never fail.")
                .build();

        //This is an option group because it can be specified more then once.
        final OptionGroup og = new OptionGroup();
        og.addOption(path);

        final OptionGroup exog = new OptionGroup();
        exog.addOption(excludes);

        options.addOptionGroup(og)
                .addOptionGroup(exog)
                .addOption(projectName)
                .addOption(out)
                .addOption(outputFormat)
                .addOption(version)
                .addOption(help)
                .addOption(advancedHelp)
                .addOption(noUpdate)
                .addOption(symLinkDepth)
                .addOption(props)
                .addOption(verboseLog)
                .addOption(suppressionFile)
                .addOption(hintsFile)
                .addOption(cveValidForHours)
                .addOption(experimentalEnabled)
                .addOption(retiredEnabled)
                .addOption(failOnCVSS);
    }
1232242
private void addFileToList(final CmsFileInfo file, boolean invalid, boolean existingDeleted, boolean isTooLarge) {

        CmsListInfoBean infoBean = createInfoBean(file);
        CmsListItemWidget listItemWidget = new CmsListItemWidget(infoBean);
        listItemWidget.setIcon(CmsCoreProvider.get().getResourceTypeIcon(file));
        CmsCheckBox check = new CmsCheckBox();
        check.setChecked(false);
        if (!invalid && !isTooLarge && !existingDeleted) {
            if (file.getFileSize() == 0) {
                check.setChecked(false);
            }
            check.setChecked(m_filesToUpload.containsKey(file.getFileName()));
            check.setTitle(file.getFileName());
            if (!m_selectionDone && file.getFileName().toLowerCase().endsWith(".zip")) {
                final Widget unzip = createUnzipCheckBox(file);
                addClickHandlerToCheckBox(check, unzip, file);
                listItemWidget.addButton(unzip);
            } else {
                addClickHandlerToCheckBox(check, null, file);
            }
        } else if (existingDeleted) {
            // is invalid
            String message = Messages.get().key(Messages.GUI_UPLOAD_FILE_EXISTING_DELETED_1, file.getFileName());
            check.disable(message);
            listItemWidget.setBackground(Background.RED);
            listItemWidget.setSubtitleLabel(message);
        } else if (isTooLarge) {
            String message = getFileSizeTooLargeMessage(file);
            check.disable(message);
            listItemWidget.setBackground(Background.RED);
            listItemWidget.setSubtitleLabel(message);
        } else {
            // is invalid
            String message = Messages.get().key(
                Messages.GUI_UPLOAD_FILE_INVALID_NAME_2,
                file.getFileName(),
                CmsUploadButton.formatBytes(file.getFileSize()));
            check.disable(message);
            listItemWidget.setBackground(Background.RED);
            listItemWidget.setSubtitleLabel(message);
        }

        CmsListItem listItem = new CmsListItem(check, listItemWidget);
        m_fileList.addItem(listItem);
        m_listItems.put(file.getFileName(), listItem);
        doResize();
    }
604427
def options(self, parser, env):
        
        Plugin.options(self, parser, env)
        parser.add_option('--filetype', action='append',
                          help='Specify additional filetypes to monitor.')
925916
private function appendCollectedFileAndChanges(): void
    {
        if (!empty($this->currentFile)) {
            foreach ($this->currentChanges as $change) {
                $this->currentFile->addChange($change);
            }
            $this->files[] = $this->currentFile;
        }
        $this->currentChanges = [];
    }
1232166
def fix_config(self, options):
        
        options = super(FileSupplier, self).fix_config(options)

        opt = "files"
        if opt not in options:
            options[opt] = []
        if opt not in self.help:
            self.help[opt] = "The files to output (list of string)."

        return options
846135
def add_options(self):
        
        super(RtorrentControl, self).add_options()

        # basic options
        self.add_bool_option("--help-fields",
            help="show available fields and their description")
        self.add_bool_option("-n", "--dry-run",
            help="don't commit changes, just tell what would happen")
        self.add_bool_option("--detach",
            help="run the process in the background")
        self.prompt.add_options()

        # output control
        self.add_bool_option("-S", "--shell",
            help="escape output following shell rules")
        self.add_bool_option("-0", "--nul", "--print0",
            help="use a NUL character instead of a linebreak after items")
        self.add_bool_option("-c", "--column-headers",
            help="print column headers")
        self.add_bool_option("-+", "--stats",
            help="add sum / avg / median of numerical fields")
        self.add_bool_option("--summary",
            help="print only statistical summary, without the items")
        #self.add_bool_option("-f", "--full",
        #    help="print full torrent details")
        self.add_bool_option("--json",
            help="dump all items as JSON (use '-o f1,f2,...' to specify fields)")
        self.add_value_option("-o", "--output-format", "FORMAT",
            help="specify display format (use '-o-' to disable item display)")
        self.add_value_option("-O", "--output-template", "FILE",
            help="pass control of output formatting to the specified template")
        self.add_value_option("-s", "--sort-fields", "[-]FIELD[,...] [-s...]",
            action='append', default=[],
            help="fields used for sorting, descending if prefixed with a '-'; '-s*' uses output field list")
        self.add_bool_option("-r", "--reverse-sort",
            help="reverse the sort order")
        self.add_value_option("-A", "--anneal", "MODE [-A...]",
            type='choice', action='append', default=[],
            choices=('dupes+', 'dupes-', 'dupes=', 'invert', 'unique'),
            help="modify result set using some pre-defined methods")
        self.add_value_option("-/", "--select", "[N-]M",
            help="select result subset by item position (counting from 1)")
        self.add_bool_option("-V", "--view-only",
            help="show search result only in default ncurses view")
        self.add_value_option("--to-view", "--to", "NAME",
            help="show search result only in named ncurses view")
        self.add_bool_option("--append-view", "--append",
            help="DEPRECATED: use '--alter append' instead")
        self.add_value_option("--alter-view", "--alter", "MODE",
            type='choice', default=None, choices=self.ALTER_MODES,
            help="alter view according to mode: {} (modifies -V and --to behaviour)"
                 .format(', '.join(self.ALTER_MODES)))
        self.add_bool_option("--tee-view", "--tee",
            help="ADDITIONALLY show search results in ncurses view (modifies -V and --to behaviour)")
        self.add_value_option("--from-view", "--from", "NAME",
            help="select only items that are on view NAME (NAME can be an info hash to quickly select a single item)")
        self.add_value_option("-M", "--modify-view", "NAME",
            help="get items from given view and write result back to it (short-cut to combine --from-view and --to-view)")
        self.add_value_option("-Q", "--fast-query", "LEVEL",
            type='choice', default='=', choices=('=', '0', '1', '2'),
            help="enable query optimization (=: use config; 0: off; 1: safe; 2: danger seeker)")
        self.add_value_option("--call", "CMD",
            help="call an OS command pattern in the shell")
        self.add_value_option("--spawn", "CMD [--spawn ...]",
            action="append", default=[],
            help="execute OS command pattern(s) directly")
# TODO: implement -S
#        self.add_bool_option("-S", "--summary",
#            help="print statistics")

        # torrent state change (actions)
        for action in self.ACTION_MODES:
            action.setdefault("label", action.name.upper())
            action.setdefault("method", action.name)
            action.setdefault("interactive", False)
            action.setdefault("argshelp", "")
            action.setdefault("args", ())
            if action.argshelp:
                self.add_value_option(*action.options + (action.argshelp,),
                    **{"help": action.help + (" (implies -i)" if action.interactive else "")})
            else:
                self.add_bool_option(*action.options,
                    **{"help": action.help + (" (implies -i)" if action.interactive else "")})
        self.add_value_option("--ignore", "|".join(self.IGNORE_OPTIONS),
            type="choice", choices=self.IGNORE_OPTIONS,
            help="set 'ignore commands' status on torrent")
        self.add_value_option("--prio", "|".join(self.PRIO_OPTIONS),
            type="choice", choices=self.PRIO_OPTIONS,
            help="set priority of torrent")
        self.add_bool_option("-F", "--flush", help="flush changes immediately (save session data)")
824013
public function modifyFile()
    {
        foreach (['chown', 'chgrp', 'chmod'] as $key) {
            $value = $this->{$key};
            if ($value) {
                $this->file->{$key}($value);
            }
        }
    }
1267828
private void processOptions(OptionSet options) {
    Pseudorandom.get().setSeed(options.valueOf(randomSeed));

    if (opts.contains(CommonOptions.MAP_REDUCE)) {
      MapReduceConfiguration.setMapReduceExecutor(new LocalMapReduceExecutor(
          options.valueOf(mrMaxThreads), options.valueOf(mrMaxBatchesPerThread)));
    }

    if (opts.contains(CommonOptions.STOCHASTIC_GRADIENT) || opts.contains(CommonOptions.LBFGS)) {
      LogFunction log = null;
      if (parsedOptions.has(logBrief)) {
        log = new NullLogFunction();
      } else {
         log = new DefaultLogFunction(parsedOptions.valueOf(logInterval), false,
             options.valueOf(logParametersInterval), options.valueOf(logParametersDir));
      }
      LogFunctions.setLogFunction(log);
    }
  }
1138067
@SuppressWarnings("static-access")
	private static void initOptions() {

		List<String> actions = new ArrayList<>(KNOWN_ACTIONS.keySet());
		Collections.sort(actions);
		Option action = OptionBuilder
				.hasArg()
				.withArgName("action")
				.withDescription(
						"define the action that should be performed; avaible actions: "
								+ actions).withLongOpt(OPTION_ACTION)
				.create(CMD_OPTION_ACTION);

		Option destination = OptionBuilder.withArgName("path").hasArg()
				.withDescription("place the output into the file at <path>")
				.withLongOpt(OPTION_OUTPUT_DESTINATION)
				.create(CMD_OPTION_OUTPUT_DESTINATION);

		Option dumplocation = OptionBuilder
				.hasArg()
				.withArgName("path")
				.withDescription(
						"set the directory where downloaded dump files are stored")
				.withLongOpt(OPTION_DUMP_LOCATION)
				.create(CMD_OPTION_DUMP_LOCATION);

		Option config = OptionBuilder
				.hasArg()
				.withArgName("file")
				.withDescription(
						"set a config file; use this to define multiple actions for a single run")
				.withLongOpt(OPTION_CONFIG_FILE).create(CMD_OPTION_CONFIG_FILE);

		Option rdfdump = OptionBuilder
				.hasArgs()
				.withArgName("task")
				.withDescription(
						"specify which data to include in RDF dump (use with action \"rdf\"); run with options \"-a rdf -n\" for help")
				.withLongOpt(OPTION_OUTPUT_RDF_TYPE).create();

		Option filterLanguages = OptionBuilder
				.hasArgs()
				.withArgName("languages")
				.withDescription(
						"specifies a list of language codes; if given, only terms in languages in this list will be processed; the value \"-\" denotes the empty list (no terms are processed)")
				.withLongOpt(OPTION_FILTER_LANGUAGES).create();

		Option filterSites = OptionBuilder
				.hasArgs()
				.withArgName("sites")
				.withDescription(
						"specifies a list of site keys; if given, only site links to sites in this list will be processed; the value \"-\" denotes the empty list (no site links are processed)")
				.withLongOpt(OPTION_FILTER_SITES).create();

		Option filterProperties = OptionBuilder
				.hasArgs()
				.withArgName("ids")
				.withDescription(
						"specifies a list of property ids; if given, only statements for properties in this list will be processed; the value \"-\" denotes the empty list (no statements are processed)")
				.withLongOpt(OPTION_FILTER_PROPERTIES).create();

		Option compressionExtention = OptionBuilder
				.hasArg()
				.withArgName("type")
				.withDescription(
						"define a compression format to be used for the output; possible values: "
								+ DumpProcessingOutputAction.COMPRESS_GZIP
								+ ", "
								+ DumpProcessingOutputAction.COMPRESS_BZ2)
				.withLongOpt(OPTION_OUTPUT_COMPRESSION)
				.create(CMD_OPTION_OUTPUT_COMPRESSION);

		Option report = OptionBuilder
				.hasArg()
				.withArgName("path")
				.withDescription(
						"specifies a path to print a final report after dump generations")
				.withLongOpt(OPTION_CREATE_REPORT)
				.create(CMD_OPTION_CREATE_REPORT);

		Option localDump = OptionBuilder
				.hasArg()
				.withArgName("path")
				.withDescription(
						"select a dump file for processing; if omitted, then the latest dump from Wikidata will be used (and possibly downloaded)")
				.withLongOpt(OPTION_LOCAL_DUMPFILE)
				.create(CMD_OPTION_LOCAL_DUMPFILE);

		options.addOption(config);
		options.addOption(action);
		options.addOption(
				CMD_OPTION_QUIET,
				OPTION_QUIET,
				false,
				"perform all actions quietly, without printing status messages to the console; errors/warnings are still printed to stderr");
		options.addOption(destination);
		options.addOption(dumplocation);
		options.addOption(filterLanguages);
		options.addOption(filterSites);
		options.addOption(filterProperties);
		options.addOption(compressionExtention);
		options.addOption(report);
		options.addOption(localDump);
		options.addOption(rdfdump);
		options.addOption(CMD_OPTION_OFFLINE_MODE, OPTION_OFFLINE_MODE, false,
				"execute all operations in offline mode, especially do not download new dumps");
		options.addOption(CMD_OPTION_HELP, OPTION_HELP, false,
				"print this message");

		options.addOption(CMD_OPTION_OUTPUT_STDOUT, OPTION_OUTPUT_STDOUT,
				false, "write output to stdout");
	}
1229273
function(options) {
			this.inputStream = options.inputStream || process.stdin;
			this.outputStream = options.outputStream || process.stdout;
		}
270008
def process_options(opts):
    """"""
    # Convert match and exclude args into pattern lists
    match = opts.get("match")
    if match and type(match) is str:
        opts["match"] = [pat.strip() for pat in match.split(",")]
    elif match:
        assert type(match) is list
    else:
        opts["match"] = []

    exclude = opts.get("exclude")
    if exclude and type(exclude) is str:
        opts["exclude"] = [pat.strip() for pat in exclude.split(",")]
    elif exclude:
        assert type(exclude) is list
    else:
        # opts["exclude"] = DEFAULT_OMIT
        opts["exclude"] = []