Java Code Examples for org.apache.commons.cli.Option#setValueSeparator()

The following examples show how to use org.apache.commons.cli.Option#setValueSeparator() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SBOLTechMapRunner.java    From iBioSim with Apache License 2.0 6 votes vote down vote up
private static Options getCommandLineOptions() {
	Option libFiles = new Option("l", "library", true, "A file or a directory of genetic gates used for technology mapping");
	libFiles.setValueSeparator(separator);
	Option preselect = new Option("ps",  "preselect", true, "Select nodes in the specification and assign with a ComponentDefinition URI.");
	preselect.setValueSeparator(separator);
	
	Options techMapOptions = new Options();
	techMapOptions.addOption("h", "help", false, "show the available command line needed to run this application.");
	techMapOptions.addOption("s", "specification", true, "A decomposed SBOL file describing the design specification");
	techMapOptions.addOption(libFiles);
	techMapOptions.addOption(preselect);
	techMapOptions.addOption("bb", "branchbound", false, "Perform branch and bound for covering"); 
	techMapOptions.addOption("e", "exhaustive", false, "Perform exhaustive for covering"); 
	techMapOptions.addOption("g", "greedy", false, "Perform greedy for covering"); 
	techMapOptions.addOption("nsol", "numOfSol", true, "Number of solution"); 
	techMapOptions.addOption("o", "outFileName", true, "Name of output file"); 
	techMapOptions.addOption("od", "odir", true, "Path of output directory where the technology mapper will produce the results to.");
	techMapOptions.addOption("sbol", false, "Export solution into SBOL");
	techMapOptions.addOption("id", "nodeId", false, "List all specification node IDs.");
	return techMapOptions;
}
 
Example 2
Source File: GateGenerationRunner.java    From iBioSim with Apache License 2.0 6 votes vote down vote up
private static Options getCommandLineOptions() {
	Option tuFiles = new Option("f", "SBOLFiles",  true, "List of SBOL files containing transcription unit designs to generate logic gates from.");
	tuFiles.setValueSeparator(separator);
	
	Options options = new Options();
	options.addOption(tuFiles);
	options.addOption("sbh", "sbhRepository", true, "Name of SynBioHub repository to obtain get interaction data from.");
	options.addOption("h", "help", false, "show the available command line needed to run this application.");
	options.addOption("o", "outFileName", true, "Name of output file");
	options.addOption("od", "odir", true, "Path of output directory where GateGeneration stores the result.");
	options.addOption("NOT", false, "Export NOT gates");
	options.addOption("NOR", false, "Export NOR gates");
	options.addOption("OR", false, "Export OR gates");
	options.addOption("WiredOR", false, "Export Wired OR gates");
	options.addOption("NAND", false, "Export NAND gates");
	options.addOption("AND", false, "Export AND gates");
	options.addOption("NOTSUPPORTED", false, "Export gates not identified.");
	options.addOption("all", false, "Export all gates into an SBOL file."); 
	return options;
}
 
Example 3
Source File: VerilogRunner.java    From iBioSim with Apache License 2.0 6 votes vote down vote up
private static Options getCommandLineOptions() {
	Option verilogFiles = new Option("v", "verilogFiles",  true, "compile the given verilog file(s).");
	verilogFiles.setValueSeparator(separator);

	Options options = new Options();
	options.addOption(verilogFiles);
	options.addOption("h", "help", false, "show the available command line needed to run this application.");
	options.addOption("lpn", false, "Export result of the compiler to an LPN model."  +
			"Note that the LPN model produced in this compiler is limited to converting one implementation verilog file and its testbench file to LPN. " +
			"If the testbench file has more than one submodule instantiated, the user must specificy the name of the implementation verilog module and the name of the testbench verilog module for the compiler to produce a valid LPN model. " +
			"These fields should be set by specifying the -tb and -imp command.");
	options.addOption("sbml", false, "Export result of the compiler to SBML.");
	options.addOption("o", "outFileName", true, "Name of output file when exporting result of compiler to an LPN model.");
	options.addOption("od", "odir", true, "Path of output directory where the compiler will produce the results to.");
	options.addOption("tb", "tb_modId", true, "Name of the testbench verilog module identifier that simulates the design.");
	options.addOption("imp", "imp_modId", true, "Name of the implemenation verilog module identifier that describes the circuit");
	options.addOption("sbol", false, "Output data into SBOL.");
	options.addOption("flat", false, "Export data model as a flat model.");
	return options;
}
 
Example 4
Source File: Main.java    From swift-t with Apache License 2.0 6 votes vote down vote up
private static Options initOptions() {
  Options opts = new Options();

  Option module = new Option(INCLUDE_FLAG, "include", true,
                                  "Add to import search path");
  opts.addOption(module);

  Option arg = new Option(SWIFT_PROG_ARG_FLAG, "arg", true,
      "Compile-time argument");
  arg.setArgs(2);
  arg.setValueSeparator('=');
  opts.addOption(arg);

  Option preprocArg = new Option(PREPROC_MACRO_FLAG, true,
                                  "Preprocessor definition");
  opts.addOption(preprocArg);

  opts.addOption(UPDATE_FLAG, false, "Update output only if out of date");
  return opts;
}
 
Example 5
Source File: OptionBuilder.java    From datawave with Apache License 2.0 5 votes vote down vote up
/**
 * Creates an Option using OptionBuilder's State and the given parameters.
 *
 * @param opt
 *            short representation of the option
 * @param longOpt
 *            long representation of the option
 * @param desc
 *            descibes the function of the option
 * @return the new Option
 */
public Option create(final String opt, final String longOpt, final String desc) {
    final Option option = new Option(opt, desc);
    option.setLongOpt(longOpt);
    option.setArgs(args);
    option.setRequired(required);
    option.setOptionalArg(optionalArg);
    option.setType(type);
    option.setValueSeparator(valSeparator);
    
    return option;
}
 
Example 6
Source File: CliModel.java    From seed with Mozilla Public License 2.0 5 votes vote down vote up
CliModel(Set<Field> fields) {
    for (Field field : fields) {
        CliOption optionAnnotation = field.getAnnotation(CliOption.class);
        CliArgs argsAnnotation = field.getAnnotation(CliArgs.class);

        if (optionAnnotation != null) {
            Option option = new Option(
                    optionAnnotation.name(),
                    optionAnnotation.longName(),
                    optionAnnotation.valueCount() > 0 || optionAnnotation.valueCount() == -1,
                    optionAnnotation.description()
            );

            if (optionAnnotation.valueCount() == -1) {
                option.setArgs(Option.UNLIMITED_VALUES);
            } else if (optionAnnotation.valueCount() > 0) {
                option.setArgs(optionAnnotation.valueCount());
            }

            option.setValueSeparator(optionAnnotation.valueSeparator());
            option.setRequired(optionAnnotation.mandatory());
            option.setOptionalArg(!optionAnnotation.mandatoryValue());
            optionAnnotations.add(optionAnnotation);
            optionFields.add(field);
            options.addOption(option);
        } else if (argsAnnotation != null) {
            mandatoryArgsCount = argsAnnotation.mandatoryCount();
            argsField = field;
        }
    }
}
 
Example 7
Source File: NodeCLI.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@Override
public int run(String[] args) throws Exception {

  Options opts = new Options();
  opts.addOption(HELP_CMD, false, "Displays help for all commands.");
  opts.addOption(STATUS_CMD, true, "Prints the status report of the node.");
  opts.addOption(LIST_CMD, false, "List all running nodes. " +
      "Supports optional use of -states to filter nodes " +
      "based on node state, all -all to list all nodes.");
  Option nodeStateOpt = new Option(NODE_STATE_CMD, true,
      "Works with -list to filter nodes based on input comma-separated list of node states.");
  nodeStateOpt.setValueSeparator(',');
  nodeStateOpt.setArgs(Option.UNLIMITED_VALUES);
  nodeStateOpt.setArgName("States");
  opts.addOption(nodeStateOpt);
  Option allOpt = new Option(NODE_ALL, false,
      "Works with -list to list all nodes.");
  opts.addOption(allOpt);
  opts.getOption(STATUS_CMD).setArgName("NodeId");

  int exitCode = -1;
  CommandLine cliParser = null;
  try {
    cliParser = new GnuParser().parse(opts, args);
  } catch (MissingArgumentException ex) {
    sysout.println("Missing argument for options");
    printUsage(opts);
    return exitCode;
  }

  if (cliParser.hasOption("status")) {
    if (args.length != 2) {
      printUsage(opts);
      return exitCode;
    }
    printNodeStatus(cliParser.getOptionValue("status"));
  } else if (cliParser.hasOption("list")) {
    Set<NodeState> nodeStates = new HashSet<NodeState>();
    if (cliParser.hasOption(NODE_ALL)) {
      for (NodeState state : NodeState.values()) {
        nodeStates.add(state);
      }
    } else if (cliParser.hasOption(NODE_STATE_CMD)) {
      String[] types = cliParser.getOptionValues(NODE_STATE_CMD);
      if (types != null) {
        for (String type : types) {
          if (!type.trim().isEmpty()) {
            nodeStates.add(NodeState.valueOf(
                org.apache.hadoop.util.StringUtils.toUpperCase(type.trim())));
          }
        }
      }
    } else {
      nodeStates.add(NodeState.RUNNING);
    }
    listClusterNodes(nodeStates);
  } else if (cliParser.hasOption(HELP_CMD)) {
    printUsage(opts);
    return 0;
  } else {
    syserr.println("Invalid Command Usage : ");
    printUsage(opts);
  }
  return 0;
}
 
Example 8
Source File: NodeCLI.java    From big-c with Apache License 2.0 4 votes vote down vote up
@Override
public int run(String[] args) throws Exception {

  Options opts = new Options();
  opts.addOption(HELP_CMD, false, "Displays help for all commands.");
  opts.addOption(STATUS_CMD, true, "Prints the status report of the node.");
  opts.addOption(LIST_CMD, false, "List all running nodes. " +
      "Supports optional use of -states to filter nodes " +
      "based on node state, all -all to list all nodes.");
  Option nodeStateOpt = new Option(NODE_STATE_CMD, true,
      "Works with -list to filter nodes based on input comma-separated list of node states.");
  nodeStateOpt.setValueSeparator(',');
  nodeStateOpt.setArgs(Option.UNLIMITED_VALUES);
  nodeStateOpt.setArgName("States");
  opts.addOption(nodeStateOpt);
  Option allOpt = new Option(NODE_ALL, false,
      "Works with -list to list all nodes.");
  opts.addOption(allOpt);
  opts.getOption(STATUS_CMD).setArgName("NodeId");

  int exitCode = -1;
  CommandLine cliParser = null;
  try {
    cliParser = new GnuParser().parse(opts, args);
  } catch (MissingArgumentException ex) {
    sysout.println("Missing argument for options");
    printUsage(opts);
    return exitCode;
  }

  if (cliParser.hasOption("status")) {
    if (args.length != 2) {
      printUsage(opts);
      return exitCode;
    }
    printNodeStatus(cliParser.getOptionValue("status"));
  } else if (cliParser.hasOption("list")) {
    Set<NodeState> nodeStates = new HashSet<NodeState>();
    if (cliParser.hasOption(NODE_ALL)) {
      for (NodeState state : NodeState.values()) {
        nodeStates.add(state);
      }
    } else if (cliParser.hasOption(NODE_STATE_CMD)) {
      String[] types = cliParser.getOptionValues(NODE_STATE_CMD);
      if (types != null) {
        for (String type : types) {
          if (!type.trim().isEmpty()) {
            nodeStates.add(NodeState.valueOf(
                org.apache.hadoop.util.StringUtils.toUpperCase(type.trim())));
          }
        }
      }
    } else {
      nodeStates.add(NodeState.RUNNING);
    }
    listClusterNodes(nodeStates);
  } else if (cliParser.hasOption(HELP_CMD)) {
    printUsage(opts);
    return 0;
  } else {
    syserr.println("Invalid Command Usage : ");
    printUsage(opts);
  }
  return 0;
}
 
Example 9
Source File: GridVmNodesStarter.java    From ignite with Apache License 2.0 4 votes vote down vote up
/**
 * Creates cli options.
 *
 * @return Command line options
 */
private static Options createOptions() {
    Options options = new Options();

    OptionGroup grp = new OptionGroup();

    grp.setRequired(true);

    Option cfg = new Option(OPTION_CFG, null, true, "path to Spring XML configuration file.");

    cfg.setArgName("file");

    Option n = new Option(null, OPTION_N, true, "nodes count.");

    n.setValueSeparator('=');
    n.setType(Integer.class);

    grp.addOption(cfg);
    grp.addOption(n);

    options.addOptionGroup(grp);

    return options;
}
 
Example 10
Source File: ResourceMonitorMain.java    From kieker with Apache License 2.0 4 votes vote down vote up
@Override
protected void addAdditionalOptions(final Options options) {
	final Option intervalOption = new Option(null, "interval", true, "Sampling interval");
	intervalOption.setArgName("interval");
	intervalOption.setRequired(false);
	intervalOption.setArgs(1);
	options.addOption(intervalOption);

	final Option intervalUnitOption = new Option(null, "interval-unit", true, "Sampling interval time unit (default: SECONDS)");
	intervalUnitOption.setArgName("interval-unit");
	intervalUnitOption.setRequired(false);
	intervalUnitOption.setArgs(1);
	options.addOption(intervalUnitOption);

	final Option initialDelayOption = new Option(null, "initial-delay", true, "Initial delay");
	initialDelayOption.setArgName("initial-delay");
	initialDelayOption.setRequired(false);
	initialDelayOption.setArgs(1);
	options.addOption(initialDelayOption);

	final Option durationUnitOption = new Option(null, "initial-delay-unit", true, "Initial delay time unit (default: SECONDS)");
	durationUnitOption.setArgName("initial-delay-unit");
	durationUnitOption.setRequired(false);
	durationUnitOption.setArgs(1);
	options.addOption(durationUnitOption);

	final Option initialDelayUnitOption = new Option(null, "duration", true, "Monitoring duration");
	initialDelayUnitOption.setArgName("duration");
	initialDelayUnitOption.setRequired(false);
	initialDelayUnitOption.setArgs(1);
	options.addOption(initialDelayUnitOption);

	final Option durationOption = new Option(null, "duration-unit", true, "Monitoring duration time unit (default: MINUTES)");
	durationOption.setArgName("duration-unit");
	durationOption.setRequired(false);
	durationOption.setArgs(1);
	options.addOption(durationOption);

	final Option configurationFileOption = new Option("c", CMD_OPT_NAME_MONITORING_CONFIGURATION, true,
			"Configuration to use for the Kieker monitoring instance");
	configurationFileOption.setArgName(OPTION_EXAMPLE_FILE_MONITORING_PROPERTIES);
	configurationFileOption.setRequired(false);
	configurationFileOption.setValueSeparator('=');
	options.addOption(configurationFileOption);
}
 
Example 11
Source File: GridRandomCommandLineLoader.java    From ignite with Apache License 2.0 2 votes vote down vote up
/**
 * Creates cli options.
 *
 * @return Command line options
 */
private static Options createOptions() {
    Options options = new Options();

    Option help = new Option(OPTION_HELP, "print this message");

    Option cfg = new Option(null, OPTION_CFG, true, "path to Spring XML configuration file.");

    cfg.setValueSeparator('=');
    cfg.setType(String.class);

    Option minTtl = new Option(null, OPTION_MIN_TTL, true, "node minimum time to live.");

    minTtl.setValueSeparator('=');
    minTtl.setType(Long.class);

    Option maxTtl = new Option(null, OPTION_MAX_TTL, true, "node maximum time to live.");

    maxTtl.setValueSeparator('=');
    maxTtl.setType(Long.class);

    Option duration = new Option(null, OPTION_DURATION, true, "run timeout.");

    duration.setValueSeparator('=');
    duration.setType(Long.class);

    Option log = new Option(null, OPTION_LOG_CFG, true, "path to log4j configuration file.");

    log.setValueSeparator('=');
    log.setType(String.class);

    options.addOption(help);

    OptionGroup grp = new OptionGroup();

    grp.setRequired(true);

    grp.addOption(cfg);
    grp.addOption(minTtl);
    grp.addOption(maxTtl);
    grp.addOption(duration);
    grp.addOption(log);

    options.addOptionGroup(grp);

    return options;
}