List of usage examples for org.apache.commons.cli Option setRequired
public void setRequired(boolean required)
From source file:de.uni_koblenz.jgralab.utilities.schemacompare.SchemaCompare.java
private static CommandLine processCommandLineOptions(String[] args) { String toolString = "java " + SchemaCompare.class.getName(); String versionString = JGraLab.getInfo(false); OptionHandler oh = new OptionHandler(toolString, versionString); Option schema1 = new Option("s1", "schema1", true, "(required): the first schema which is compared with the second"); schema1.setRequired(true); schema1.setArgName("file"); oh.addOption(schema1);// ww w . ja va 2 s. c o m Option schema2 = new Option("s2", "schema2", true, "(required): the second schema which is compared with the first"); schema2.setRequired(true); schema2.setArgName("file"); oh.addOption(schema2); return oh.parse(args); }
From source file:de.uni_koblenz.jgralab.utilities.converter.TGraphToTGraph2Converter.java
private static CommandLine processCommandLineOptions(String[] args) { String toolString = "java " + TGraphToTGraph2Converter.class.getName(); String versionString = JGraLab.getInfo(false); OptionHandler oh = new OptionHandler(toolString, versionString); Option input = new Option("i", "input", true, "(optional): input TG file, if omitted, the tool reads from stdin"); input.setRequired(false); input.setArgName("file"); oh.addOption(input);/*from w w w . j a va2s .c om*/ Option output = new Option("o", "output", true, "(optional): output TG file, if omitted, the tool writes to stdout"); output.setRequired(false); output.setArgName("file"); oh.addOption(output); Option loadSchemaAfterConversion = new Option("l", "load", false, "(optional): loads the schema after conversion and displays errors if it did't work"); loadSchemaAfterConversion.setRequired(false); oh.addOption(loadSchemaAfterConversion); return oh.parse(args); }
From source file:kieker.develop.rl.cli.CLICompilerMain.java
/** * Compile the options for the CLI server. * * @return The composed options for the CLI server *//*from ww w . j ava 2s.c o m*/ private static Options declareOptions() { options = new Options(); Option option; // runtime root option = new Option(CMD_ROOT, CMD_ROOT_LONG, true, "Root folder of eclipse platfrom/workspace."); option.setArgName(CMD_ROOT); option.setRequired(true); options.addOption(option); // eclipse project name option = new Option(CMD_PROJECT, CMD_PROJECT_LONG, true, "Eclipse project containing the files."); option.setArgName(CMD_PROJECT); option.setRequired(true); options.addOption(option); // eclipse project path name option = new Option(CMD_PROJECT_DIRECTORY, CMD_PROJECT_DIRECTORY_LONG, true, "Directory path name of the project (normally determined automatically)."); option.setArgName(CMD_PROJECT_DIRECTORY); option.setRequired(false); options.addOption(option); // project relative source folder option = new Option(CMD_SOURCE, CMD_SOURCE_LONG, true, "Project relative source folder."); option.setArgName(CMD_SOURCE); option.setRequired(false); options.addOption(option); // project relative target folder option = new Option(CMD_DESTINATION, CMD_DESTINATION_LONG, true, "Project relative destination folder."); option.setArgName(CMD_DESTINATION); option.setRequired(false); options.addOption(option); // use language specific target folders option = new Option(CMD_MAVEN_FOLDER_LAYOUT, CMD_MAVEN_FOLDER_LAYOUT_LONG, false, "Use language specific destination folders (maven layout)."); option.setArgName(CMD_MAVEN_FOLDER_LAYOUT); option.setRequired(false); options.addOption(option); // select languages option = new Option(CMD_LANGUAGES, CMD_LANGUAGES_LONG, true, "Generate code for all named languages."); option.setArgName(CMD_LANGUAGES); option.setRequired(true); options.addOption(option); // set author for the generated code option = new Option(CMD_AUTHOR, CMD_AUHTOR_LONG, true, "Set author name for the generated code. Default is 'generated'."); option.setArgName(CMD_AUTHOR); option.setRequired(false); options.addOption(option); // set author for the generated code option = new Option(CMD_VERSION, CMD_VERSION_LONG, true, "Set version for the generated code. Default is 'none'."); option.setArgName(CMD_VERSION); option.setRequired(false); options.addOption(option); return options; }
From source file:com.twitter.hraven.etl.JobFileRawLoader.java
/** * Parse command-line arguments./*from w w w.j a v a 2 s. c o m*/ * * @param args * command line arguments passed to program. * @return parsed command line. * @throws ParseException */ 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); o = new Option("p", "processFileSubstring", true, "use only those process records where the process file path contains the provided string. Useful when processing production jobs in parallel to historic loads."); o.setArgName("processFileSubstring"); o.setRequired(false); options.addOption(o); // Force o = new Option("f", "forceReprocess", false, "Force all jobs for which a jobFile is loaded to be reprocessed. Optional. Default is false."); 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; }
From source file:com.opengamma.component.tool.AbstractDbTool.java
private static Option createConfigOption() { Option option = new Option(CONFIG_RESOURCE_OPTION, "config", true, "the database tool context configuration resource"); option.setArgName("resource"); option.setRequired(true); return option; }
From source file:gpframework.RunExperiment.java
/** * Generates a list of command line options for this program. * @param options reference to options./*from ww w. j ava2s .co m*/ */ private static void setupOptions(Options options) { Option opt; opt = new Option("t", "timeBudget", true, "maximum number of seconds to run each repetition of the experiment, e.g. 14400 seconds"); opt.setRequired(true); options.addOption(opt); opt = new Option("e", "evaluationsBudget", true, "maximum number of evaluations for each experiment, e.g. 250.000"); opt.setRequired(true); options.addOption(opt); opt = new Option("n", "inputSize", true, "problem input size, e.g. sorting n numbers"); opt.setRequired(true); options.addOption(opt); opt = new Option("d", "debug", false, "enables debug messages"); options.addOption(opt); opt = new Option("c", "cluster", false, "enables cluster mode"); options.addOption(opt); // Problem options opt = new Option("ff", "FunctionFactory", true, "function factory for generating function nodes, e.g. JoinFactory"); opt.setRequired(true); options.addOption(opt); opt = new Option("tf", "TerminalFactory", true, "terminal factory for generating terminal nodes, e.g. TerminalFactory"); opt.setRequired(true); options.addOption(opt); opt = new Option("pf", "ProgramFactory", true, "program factory for generating programs, e.g. SortingProgramFactory"); opt.setRequired(true); options.addOption(opt); opt = new Option("f", "FitnessFunction", true, "fitness function to use, e.g. HamSortednessFunction"); opt.setRequired(true); options.addOption(opt); // Algorithm options opt = new Option("a", "Algorithm", true, "algorithm to use, e.g. Algorithm or SMOGP"); opt.setRequired(true); options.addOption(opt); opt = new Option("s", "Selection", true, "selection criterion to generate new population from offsprings, e.g. StrictSelection, ParsimonySelection"); opt.setRequired(true); options.addOption(opt); opt = new Option("mf", "MutationFactory", true, "factory to generate mutations, e.g. SingleMutationFactory, PoissonMutationFactory"); opt.setRequired(true); options.addOption(opt); opt = new Option("bn", "batchName", true, "batch name to store on MongoDB"); opt.setRequired(true); options.addOption(opt); }
From source file:de.uni_koblenz.jgralab.utilities.greqlserver.GReQLConsole.java
private static CommandLine processCommandLineOptions(String[] args) { String toolString = "java " + GReQLConsole.class.getName(); String versionString = JGraLab.getInfo(false); OptionHandler oh = new OptionHandler(toolString, versionString); Option queryfile = new Option("q", "queryfile", true, "(required): queryfile which should be executed. May contain " + "many queries separated by //-- on a line"); queryfile.setRequired(true); queryfile.setArgName("file"); oh.addOption(queryfile);//from w w w . j a v a 2 s. co m Option inputFile = new Option("g", "graph", true, "(optional): the tg-file of the graph"); inputFile.setRequired(false); inputFile.setArgName("file"); oh.addOption(inputFile); Option output = new Option("o", "output", true, "(optional): result file to be generated (see option --output-type, defaults to html)"); output.setArgName("file"); oh.addOption(output); Option outputType = new Option("t", "output-type", true, "(optional): if -o is given, the output type to use (txt, html, or xml)"); outputType.setArgName("type"); oh.addOption(outputType); Option loadschema = new Option("s", "loadschema", false, "(optional): Loads also the schema from the file"); oh.addOption(loadschema); Option verbose = new Option("v", "verbose", false, "(optional): Produce verbose output"); oh.addOption(verbose); return oh.parse(args); }
From source file:com.opengamma.component.tool.AbstractComponentTool.java
private static Option createComponentServerOption() { Option option = new Option(COMPONENT_SERVER_URI_OPTION, "componentServer", true, "the component server, host[:port]"); option.setArgName("component server"); option.setRequired(true); return option; }
From source file:eu.project.ttc.tools.cli.TermSuiteCLIUtils.java
/** * Creates a mandatory {@link Option} using the specified arguments. * /* www. j ava 2 s .c o m*/ * @param opt * The name of the option * @param longOpt * The long representation of the option * @param hasArg * Specifies whether the Option takes an argument or not * @param description * Describes the function of the option * @param isMandatory * whether the Option is mandatory * @return The option instance */ public static Option createOption(String opt, String longOpt, boolean hasArg, String description, boolean isMandatory) { Option option = new Option(opt, longOpt, hasArg, description); option.setRequired(isMandatory); return option; }
From source file:co.cask.cdap.data.tools.flow.FlowQueuePendingCorrector.java
private static Option createOption(String opt, String longOpt, boolean hasOpt, String desc, boolean required) { Option option = new Option(opt, longOpt, hasOpt, desc); if (required) { option.setRequired(true); }//from w ww. jav a2 s . c om return option; }