List of usage examples for org.apache.commons.cli Option setArgName
public void setArgName(String argName)
From source file:com.mgmtp.perfload.perfmon.PerfMon.java
static CommandLine parseArgs(final String[] args) { Options options = new Options(); try {/*ww w .ja v a 2 s. c om*/ Option option = new Option("i", "interval", true, "The interval for printing the system information (default 5 sec)."); option.setArgName("SECONDS"); options.addOption(option); option = new Option("f", "file", true, "The output file the information is written to. Stdout is used if no file is specified."); option.setArgName("FILE"); options.addOption(option); options.addOption("c", "csv", false, "Write all data in one line for easier import in tools such as Excel."); options.addOption("j", "java", false, "Write information on Java processes."); options.addOption("t", "tcp", false, "Write TCP connection information."); options.addOption("n", "netstat", false, "Write network statistics"); options.addOption("s", "shutdown", false, "Shutdown all running perfMon processes on this machine."); options.addOption("h", "help", false, "Prints usage information."); CommandLineParser parser = new PosixParser(); CommandLine cmd = parser.parse(options, args); if (!cmd.hasOption('h')) { return cmd; } } catch (ParseException ex) { LOG.error(ex.getMessage(), ex); } printUsage(options); return null; }
From source file:lu.tudor.santec.dicom.gui.header.Dcm2Xml.java
private static CommandLine parse(String[] args) { Options opts = new Options(); Option basedir = new Option("d", true, "store extracted values in files under <basedir>. Cannot be " + "specified together with option -o <xmlfile>."); basedir.setArgName("basedir"); opts.addOption(basedir);// ww w .j ava2 s . c o m Option xmlfile = new Option("o", true, "file to write XML to, standard output by default"); xmlfile.setArgName("xmlfile"); opts.addOption(xmlfile); Option exclude = new Option("x", true, "tag (e.g.: 7FE00010) or name (e.g.: PixelData) of attribute " + "to exclude from XML output"); exclude.setArgName("tag"); opts.addOption(exclude); opts.addOption("X", false, "exclude pixel data from XML output " + "(= shortcut for -x 7FE00010)."); Option xslurl = new Option("T", true, "transform XML output by applying specified XSL stylesheet."); xslurl.setArgName("xslurl"); opts.addOption(xslurl); Option xsltparams = new Option("P", true, "pass specified parameters to the XSL stylesheet."); xsltparams.setArgName("param=value,..."); xsltparams.setValueSeparator('='); xsltparams.setArgs(2); opts.addOption(xsltparams); opts.addOption("I", "incxslt", false, "enable incremental XSLT"); opts.addOption("c", "compact", false, "suppress additional whitespaces in XML output"); opts.addOption("C", "comments", false, "include attribute names as comments in XML output"); opts.addOption("h", "help", false, "print this message"); opts.addOption("V", "version", false, "print the version information and exit"); CommandLine cl = null; try { cl = new PosixParser().parse(opts, args); } catch (ParseException e) { exit("dcm2xml: " + e.getMessage()); throw new RuntimeException("unreachable"); } if (cl.hasOption('V')) { Package p = Dcm2Xml.class.getPackage(); System.out.println("dcm2xml v" + p.getImplementationVersion()); System.exit(0); } if (cl.hasOption('h') || cl.getArgList().isEmpty()) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp(USAGE, DESCRIPTION, opts, EXAMPLE); System.exit(0); } if (cl.hasOption("o") && cl.hasOption("d")) exit("dcm2xml: Option -o <xmlfile> and -d <basedir> are mutual" + "exclusive"); return cl; }
From source file:com.opengamma.component.tool.AbstractDualComponentTool.java
private static Option createDestinationComponentServerOption() { Option option = new Option(DEST_COMPONENT_SERVER_URI_OPTION, "destination-component-server", true, "the destination component server, host[:port]"); option.setArgName("source component server"); option.setRequired(true);/*w w w . ja va 2s . c om*/ return option; }
From source file:de.uni_koblenz.jgralab.utilities.tgmerge.TGMerge.java
private static CommandLine processCommandLineOptions(String[] args) { String toolString = "java " + TGMerge.class.getName(); String versionString = JGraLab.getInfo(false); OptionHandler oh = new OptionHandler(toolString, versionString); Option output = new Option("o", "outTG", true, "(required): output TG file"); output.setRequired(true);/*w w w . j ava2 s. co m*/ output.setArgName("outputTG"); oh.addOption(output); oh.setArgumentCount(Option.UNLIMITED_VALUES); oh.setArgumentName("inputTG"); oh.setOptionalArgument(false); return oh.parse(args); }
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);//from w w w . j av a 2 s. co m schema1.setArgName("file"); oh.addOption(schema1); 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.greqlinterface.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);//from w w w . j a v a 2s. c o m queryfile.setArgName("file"); oh.addOption(queryfile); 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): HTML-file to be generated"); output.setArgName("file"); oh.addOption(output); 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.AbstractTool.java
private static Option createLogbackOption() { final Option option = new Option(LOGBACK_RESOURCE_OPTION, "logback", true, "the logback configuration resource"); option.setArgName("resource"); option.setRequired(false);//from w w w. jav a 2s .c o m return option; }
From source file:com.opengamma.component.tool.AbstractTool.java
private static Option createConfigOption(final boolean mandatoryConfigResource) { final Option option = new Option(CONFIG_RESOURCE_OPTION, "config", true, "the toolcontext configuration resource"); option.setArgName("resource"); option.setRequired(mandatoryConfigResource); return option; }
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);// w w w . ja v a 2s . c o m input.setArgName("file"); oh.addOption(input); 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: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);//w w w. ja v a 2s . c o m queryfile.setArgName("file"); oh.addOption(queryfile); 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); }