List of usage examples for org.apache.commons.cli OptionBuilder withArgName
public static OptionBuilder withArgName(String name)
From source file:de.unidue.inf.is.ezdl.gframedl.EzDL.java
private static void parseCommandLine(String[] args) { CommandLine cmd = null;// w ww .jav a2 s . co m Options parserOptions = new Options(); parserOptions.addOption(OPTION_DEBUG, false, "marks this session as a debug session"); OptionBuilder.withArgName(OPTION_DIR); OptionBuilder.hasArg(); OptionBuilder.withDescription("the directory with the config files"); parserOptions.addOption(OptionBuilder.create(OPTION_DIR)); try { cmd = parser.parse(parserOptions, args); } catch (ParseException e) { HelpFormatter formatter = new HelpFormatter(); System.out.println("EzDL " + EzDLConstants.CLIENT_VERSION); formatter.printHelp("ezdl", parserOptions); System.exit(1); } if (cmd.hasOption(OPTION_DEBUG)) { System.out.println("debug option found"); sessionType = SessionType.DEBUG; } else { sessionType = DEFAULT_SESSION_TYPE; } if (cmd.hasOption(OPTION_DIR)) { String dir = cmd.getOptionValue(OPTION_DIR); Config.setPropertyDir(dir); PropertiesUtils.setPropertyDir(dir); Config.getInstance().refreshProperties(); } }
From source file:JDBCExecutor.java
static CommandLine pargeArgs(String[] args) throws ParseException { final Options opts = new Options(); try {//from w w w. j av a 2 s. c o m Option connectURL = OptionBuilder.withArgName(CONNECT_URL).withLongOpt(CONNECT_URL).isRequired() .hasArg().withDescription("Provide jdbc connectURL").create(); Option userName = OptionBuilder.withArgName(USERNAME).withLongOpt(USERNAME).isRequired(false).hasArg() .withDescription("Provide userName").create(); Option password = OptionBuilder.withArgName(PASSWORD).withLongOpt(PASSWORD).isRequired(false).hasArg() .withDescription("Provide password").create(); Option sqlFile = OptionBuilder.withArgName(SQLFILE).withLongOpt(SQLFILE).isRequired().hasArg() .withDescription("Provide sqlFile").create(); opts.addOption(connectURL).addOption(userName).addOption(password).addOption(sqlFile); CommandLineParser parser = new GnuParser(); CommandLine commandLine = parser.parse(opts, args); return commandLine; } catch (Exception e) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("java -cp ./target/*:./target/lib/*: JDBCExecutor", opts); throw e; } }
From source file:it.polimi.tower4clouds.rules.batch.BatchTool.java
@SuppressWarnings("static-access") private static Options buildOptions() { Options options = new Options(); options.addOption(OptionBuilder.withDescription("print this message").withLongOpt("help").create("h")); options.addOption(OptionBuilder.withArgName("file").hasArg() .withDescription("validate monitoring rules in the given file").withLongOpt("validate-rules") .create("v")); options.addOption(OptionBuilder.withArgName("file").hasArg() .withDescription("validate qos constraints in the given file").withLongOpt("validate-constraints") .create("c")); options.addOption(OptionBuilder.withArgName("file").hasArg().withLongOpt("make-rules") .withDescription("make monitoring rules from qos constraints in the given file").create("r")); return options; }
From source file:com.boundary.sdk.event.EventCLI.java
@SuppressWarnings("static-access") private void addCommandOption() { optionCommand = OptionBuilder.withArgName("command").hasArg() .withDescription("One of CREATE, UPDATE, OR DELETE. Default is CREATE.").create("c"); options.addOption(optionCommand);//from ww w . j a v a2 s. c o m }
From source file:bdsup2sub.cli.CommandLineOptions.java
private void createAndAddOptions() { Option help = OptionBuilder.withLongOpt("help").withDescription("Show usage information and exit.") .hasArg(false).create(HELP); options.addOption(help);/*w w w .ja v a 2 s. c o m*/ Option version = OptionBuilder.withLongOpt("version").withDescription("Show version information and exit.") .hasArg(false).create(VERSION); options.addOption(version); Option output = OptionBuilder.withLongOpt("output").withDescription("Specify output file.").hasArg() .create(OUTPUT_FILE); options.addOption(output); Option verbose = OptionBuilder.withLongOpt("verbose").withDescription("Verbose console output mode.") .hasArg(false).create(VERBOSE); options.addOption(verbose); Option loadSettings = OptionBuilder.withLongOpt("load-settings") .withDescription("Load settings stored in configuration file even if running in command-line mode.") .hasArg(false).create(LOAD_SETTINGS); options.addOption(loadSettings); Option resolution = OptionBuilder.withArgName("resolution").withLongOpt("resolution").withDescription( "Set resolution to: keep, ntsc=480, pal=576, 720p=720, 1080p=1080, 1440x1080\nDefault: keep") .hasArg().create(RESOLUTION); options.addOption(resolution); OptionGroup framerateGroup = new OptionGroup(); Option targetFrameRate = OptionBuilder.withArgName("fps").withLongOpt("fps-target").withDescription( "Synchronize target frame rate to <fps>.\nPredefined values: 24p=23.976, pal or 25p=25, ntsc or 30p=29.967, keep (preserves the source fps for BD&XML, else default)\nDefault: automatic (dumb!).") .hasArg().create(TARGET_FRAMERATE); framerateGroup.addOption(targetFrameRate); Option convertFrameRate = OptionBuilder.withArgName("src>, <trg").withLongOpt("convert-fps") .withDescription( "Convert frame rate from <src> to <trg>\nSupported values: 24p=23.976, 25p=25, 30p=29.970\nauto,<trg> detects source frame rate.") .withValueSeparator(',').hasArgs(2).create(CONVERT_FRAMERATE); framerateGroup.addOption(convertFrameRate); options.addOptionGroup(framerateGroup); Option delay = OptionBuilder.withArgName("delay").withLongOpt("delay") .withDescription("Set delay in ms\nDefault: 0.0").hasArg().create(DELAY); options.addOption(delay); Option filter = OptionBuilder.withArgName("filter").withLongOpt("filter").withDescription( "Set the filter to use for scaling.\nSupported values: bilinear, triangle, bicubic, bell, b-spline, hermite, lanczos3, mitchell\nDefault: bilinear") .hasArg().create(SCALING_FILTER); options.addOption(filter); Option paletteMode = OptionBuilder.withArgName("mode").withLongOpt("palette-mode") .withDescription("Set palette mode.\nSupported values: keep, create, dither\nDefault: create") .hasArg().create(PALETTE_MODE); options.addOption(paletteMode); Option minDisplayTime = OptionBuilder.withArgName("time").withLongOpt("minimum-time") .withDescription("Set minimum display time in ms.\nDefault: 500").hasArg().create(MIN_DISPLAY_TIME); options.addOption(minDisplayTime); Option maxTimeDiff = OptionBuilder.withArgName("time").withLongOpt("merge-time") .withDescription("Set maximum time difference for merging subtitles in ms.\nDefault: 200").hasArg() .create(MAX_TIME_DIFF); options.addOption(maxTimeDiff); OptionGroup moveGroup = new OptionGroup(); Option moveIn = OptionBuilder.withArgName("ratio, offset").withLongOpt("move-in") .withDescription("Move captions inside screen ratio <ratio>, +/- offset <offset>") .withValueSeparator(',').hasArgs(2).create(MOVE_IN); moveGroup.addOption(moveIn); Option moveOut = OptionBuilder.withArgName("ratio, offset").withLongOpt("move-out") .withDescription("Move captions outside screen ratio <ratio>, +/- offset <offset>") .withValueSeparator(',').hasArgs(2).create(MOVE_OUT); moveGroup.addOption(moveOut); options.addOptionGroup(moveGroup); Option moveX = OptionBuilder.withArgName("pos[, offset]").withLongOpt("move-x").withDescription( "Move captions horizontally from specified position. <pos> may be left, right, center\n+/- optional offset <offset> (only if moving left or right)") .withValueSeparator(',').hasOptionalArgs(2).create(MOVE_X); options.addOption(moveX); Option cropLines = OptionBuilder.withArgName("n").withLongOpt("crop-y") .withDescription("Crop the upper/lower n lines.\nDefault: 0").hasArg().create(CROP_LINES); options.addOption(cropLines); Option alphaCropThreshold = OptionBuilder.withArgName("n").withLongOpt("alpha-crop") .withDescription("Set the alpha cropping threshold.\nDefault: 10").hasArg() .create(ALPHA_CROP_THRESHOLD); options.addOption(alphaCropThreshold); Option scale = OptionBuilder.withArgName("x, y").withLongOpt("scale") .withDescription("Scale captions horizontally and vertically.\nDefault: 1.0,1.0") .withValueSeparator(',').hasArgs(2).create(SCALE); options.addOption(scale); Option exportPalette = OptionBuilder.withLongOpt("export-palette") .withDescription("Export target palette in PGCEdit format.").hasArg(false).create(EXPORT_PALETTE); options.addOption(exportPalette); Option exportForcedSubtitlesOnly = OptionBuilder.withLongOpt("forced-only") .withDescription("Export only forced subtitles (when converting from BD-SUP).").hasArg(false) .create(EXPORT_FORCED_SUBTITLES_ONLY); options.addOption(exportForcedSubtitlesOnly); Option setForcedFlag = OptionBuilder.withArgName("state").withLongOpt("force-all") .withDescription("Set or clear the forced flag for all subtitles.\nSupported values: set, clear") .hasArg().create(FORCED_FLAG); options.addOption(setForcedFlag); Option swapCrCb = OptionBuilder.withLongOpt("swap") .withDescription("Swap Cr/Cb components when loading a BD/HD-DVD sup file.").hasArg(false) .create(SWAP_CR_CB); options.addOption(swapCrCb); Option fixInvisibleFrames = OptionBuilder.withLongOpt("fix-invisible") .withDescription("Fix zero alpha frame palette for SUB/IDX and SUP/IFO.").hasArg(false) .create(FIX_INVISIBLE_FRAMES); options.addOption(fixInvisibleFrames); Option alphaThreshold = OptionBuilder.withArgName("n").withLongOpt("alpha-thr") .withDescription("Set alpha threshold 0..255 for SUB/IDX conversion.\nDefault: 80").hasArg() .create(ALPHA_THRESHOLD); options.addOption(alphaThreshold); Option luminanceLowMedThreshold = OptionBuilder.withArgName("n").withLongOpt("lum-low-med-thr") .withDescription("Set luminance lo/med threshold 0..255 for SUB/IDX conversion.\nDefault: auto") .hasArg().create(LUM_LOW_MED_THRESHOLD); options.addOption(luminanceLowMedThreshold); Option luminanceMedHighThreshold = OptionBuilder.withArgName("n").withLongOpt("lum-med-hi-thr") .withDescription("Set luminance med/hi threshold 0..255 for SUB/IDX conversion.\nDefault: auto") .hasArg().create(LUM_MED_HIGH_THRESHOLD); options.addOption(luminanceMedHighThreshold); Option languageCode = OptionBuilder.withArgName("language").withLongOpt("language") .withDescription("Set language for SUB/IDX export.\nDefault: en").hasArg().create(LANGUAGE_CODE); options.addOption(languageCode); Option paletteFile = OptionBuilder.withArgName("file").withLongOpt("palette-file") .withDescription("Load palette file for SUB/IDX conversion. Overrides default palette.").hasArg() .create(PALETTE_FILE); options.addOption(paletteFile); }
From source file:it.crs4.pydoop.mapreduce.pipes.CommandLineParser.java
void addOption(String longName, boolean required, String description, String paramName) { Option option = OptionBuilder.withArgName(paramName).hasArgs(1).withDescription(description) .isRequired(required).create(longName); options.addOption(option);/*from w w w .j a va 2 s . c o m*/ }
From source file:de.moritzrupp.stockreader.Main.java
/** * initOptions// ww w . j av a2s . co m * <p>Initializes the options for the console application</p> */ @SuppressWarnings("static-access") private static void initOptions() { Option help = new Option("h", "help", false, "prints the help message"); Option version = new Option("v", "version", false, "prints version and license information and exists"); Option price = new Option("p", "price", false, "prints only the symbol, the date and the price of the stock"); Option csv = OptionBuilder.withArgName("FILE").withLongOpt("file") .withDescription("the path and file name to the exported file").hasArg().create("f"); Option host = OptionBuilder.withArgName("HOST").withLongOpt("host") .withDescription("the SMTP host for sending mails").hasArg().withValueSeparator('=').isRequired() .create(); Option password = OptionBuilder.withArgName("PASS").withLongOpt("password") .withDescription("the password of the mail user").hasArg().withValueSeparator('=').isRequired() .create(); Option user = OptionBuilder.withArgName("USERNAME").withLongOpt("user").withDescription("the mail user") .hasArg().withValueSeparator('=').isRequired().create(); Option from = OptionBuilder.withArgName("FROM").withLongOpt("from").withDescription("the FROM address") .hasArg().withValueSeparator('=').isRequired().create(); Option to = OptionBuilder.withArgName("TO").withLongOpt("to").withDescription("the TO address").hasArg() .withValueSeparator('=').isRequired().create(); OptionGroup mailGroup = new OptionGroup(); mailGroup.addOption(host); mailGroup.addOption(user); mailGroup.addOption(password); mailGroup.addOption(from); mailGroup.addOption(to); mailGroup.setRequired(true); options = new Options(); options.addOption(help); options.addOption(version); options.addOption(price); options.addOption(csv); options.addOptionGroup(mailGroup); formatter = new HelpFormatter(); header = "Pass the stock symbols as arguments and seperate them by spaces. At least one stock symbol is required.\n" + "Example: stockreader DBK.DE SAP.DE\n\n"; footer = "\nFor more information see http://www.moritzrupp.de."; }
From source file:io.bfscan.clueweb12.DumpWarcRecordsToPlainText.java
/** * Runs this tool.//from w ww. jav a 2 s. co m */ @SuppressWarnings("static-access") public int run(String[] args) throws Exception { Options options = new Options(); options.addOption( OptionBuilder.withArgName("path").hasArg().withDescription("input path").create(INPUT_OPTION)); options.addOption( OptionBuilder.withArgName("path").hasArg().withDescription("output path").create(OUTPUT_OPTION)); CommandLine cmdline; CommandLineParser parser = new GnuParser(); try { cmdline = parser.parse(options, args); } catch (ParseException exp) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp(this.getClass().getName(), options); ToolRunner.printGenericCommandUsage(System.out); System.err.println("Error parsing command line: " + exp.getMessage()); return -1; } if (!cmdline.hasOption(INPUT_OPTION) || !cmdline.hasOption(OUTPUT_OPTION)) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp(this.getClass().getName(), options); ToolRunner.printGenericCommandUsage(System.out); return -1; } String input = cmdline.getOptionValue(INPUT_OPTION); String output = cmdline.getOptionValue(OUTPUT_OPTION); LOG.info("Tool name: " + DumpWarcRecordsToPlainText.class.getSimpleName()); LOG.info(" - input: " + input); LOG.info(" - output: " + output); JobConf conf = new JobConf(getConf(), DumpWarcRecordsToPlainText.class); conf.setJobName(DumpWarcRecordsToPlainText.class.getSimpleName() + ":" + input); conf.setNumReduceTasks(0); FileInputFormat.addInputPaths(conf, input); FileOutputFormat.setOutputPath(conf, new Path(output)); conf.setInputFormat(ClueWeb12InputFormat.class); conf.setOutputFormat(TextOutputFormat.class); conf.setMapperClass(MyMapper.class); RunningJob job = JobClient.runJob(conf); Counters counters = job.getCounters(); int numDocs = (int) counters.findCounter(Records.PAGES).getCounter(); LOG.info("Read " + numDocs + " docs."); return 0; }
From source file:fi.uta.infim.usaproxyreportgenerator.App.java
/** * Creates the options object for the CLI parser. Command line parameters * are set up here./*from ww w. j a v a 2s .c o m*/ * @return options object for CLI parser */ @SuppressWarnings("static-access") private static Options createCLIOptions() { // Command line options Options cliOptions = new Options(); cliOptions.addOption(OptionBuilder.withArgName("directory").hasArg() .withDescription("output directory for reports").create("outputDir")); cliOptions.addOption(OptionBuilder.withArgName("class").hasArg() .withDescription("full name of the data provider class").create("dataProvider")); return cliOptions; }
From source file:de.uni_rostock.goodod.tools.Configuration.java
@SuppressWarnings("static-access") private void setupCommandLineOptions() { Option config = OptionBuilder.withArgName("configFile").hasArg() .withDescription("Specify the location of the global configuration file.").withLongOpt("config") .create('c'); Option threads = OptionBuilder.withArgName("num").hasArg() .withDescription("Specify the number of threads to use.").withLongOpt("threads") .withType(Number.class).create('t'); Option similarity = OptionBuilder.withArgName("algorithm").hasArg() .withDescription("Specify the similarity measurement algorithm.").withLongOpt("similarity") .create("s"); options.addOption(config);// w w w . j ava 2s. com options.addOption(threads); options.addOption(similarity); options.addOption("h", "help", false, "Print this help text."); options.addOption("d", "debug", false, "Enable debugging."); options.addOption("1", "one-way", false, "Only do single direction comparison, not cross-comparison."); }