use of org.apache.commons.cli.Option in project hadoop by apache.
the class TimelineSchemaCreator method parseArgs.
/**
* Parse command-line arguments.
*
* @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();
// Input
Option o = new Option(ENTITY_TABLE_NAME_SHORT, "entityTableName", true, "entity table name");
o.setArgName("entityTableName");
o.setRequired(false);
options.addOption(o);
o = new Option(TTL_OPTION_SHORT, "metricsTTL", true, "TTL for metrics column family");
o.setArgName("metricsTTL");
o.setRequired(false);
options.addOption(o);
o = new Option(APP_TO_FLOW_TABLE_NAME_SHORT, "appToflowTableName", true, "app to flow table name");
o.setArgName("appToflowTableName");
o.setRequired(false);
options.addOption(o);
o = new Option(APP_TABLE_NAME_SHORT, "applicationTableName", true, "application table name");
o.setArgName("applicationTableName");
o.setRequired(false);
options.addOption(o);
// Options without an argument
// No need to set arg name since we do not need an argument here
o = new Option(SKIP_EXISTING_TABLE_OPTION_SHORT, "skipExistingTable", false, "skip existing Hbase tables and continue to create new tables");
o.setRequired(false);
options.addOption(o);
CommandLineParser parser = new PosixParser();
CommandLine commandLine = null;
try {
commandLine = parser.parse(options, args);
} catch (Exception e) {
LOG.error("ERROR: " + e.getMessage() + "\n");
HelpFormatter formatter = new HelpFormatter();
formatter.printHelp(NAME + " ", options, true);
System.exit(-1);
}
return commandLine;
}
use of org.apache.commons.cli.Option in project hive by apache.
the class HiveMetaTool method init.
@SuppressWarnings("static-access")
private void init() {
System.out.println("Initializing HiveMetaTool..");
Option help = new Option("help", "print this message");
Option listFSRoot = new Option("listFSRoot", "print the current FS root locations");
Option executeJDOQL = OptionBuilder.withArgName("query-string").hasArgs().withDescription("execute the given JDOQL query").create("executeJDOQL");
/* Ideally we want to specify the different arguments to updateLocation as separate argNames.
* However if we did that, HelpFormatter swallows all but the last argument. Note that this is
* a know issue with the HelpFormatter class that has not been fixed. We specify all arguments
* with a single argName to workaround this HelpFormatter bug.
*/
Option updateFSRootLoc = OptionBuilder.withArgName("new-loc> " + "<old-loc").hasArgs(2).withDescription("Update FS root location in the metastore to new location.Both new-loc and " + "old-loc should be valid URIs with valid host names and schemes." + "When run with the dryRun option changes are displayed but are not " + "persisted. When run with the serdepropKey/tablePropKey option " + "updateLocation looks for the serde-prop-key/table-prop-key that is " + "specified and updates its value if found.").create("updateLocation");
Option dryRun = new Option("dryRun", "Perform a dry run of updateLocation changes.When " + "run with the dryRun option updateLocation changes are displayed but not persisted. " + "dryRun is valid only with the updateLocation option.");
Option serdePropKey = OptionBuilder.withArgName("serde-prop-key").hasArgs().withValueSeparator().withDescription("Specify the key for serde property to be updated. serdePropKey option " + "is valid only with updateLocation option.").create("serdePropKey");
Option tablePropKey = OptionBuilder.withArgName("table-prop-key").hasArg().withValueSeparator().withDescription("Specify the key for table property to be updated. tablePropKey option " + "is valid only with updateLocation option.").create("tablePropKey");
cmdLineOptions.addOption(help);
cmdLineOptions.addOption(listFSRoot);
cmdLineOptions.addOption(executeJDOQL);
cmdLineOptions.addOption(updateFSRootLoc);
cmdLineOptions.addOption(dryRun);
cmdLineOptions.addOption(serdePropKey);
cmdLineOptions.addOption(tablePropKey);
}
use of org.apache.commons.cli.Option in project hbase by apache.
the class TestJoinedScanners method main.
/**
* Command line interface:
* @param args
* @throws IOException if there is a bug while reading from disk
*/
public static void main(final String[] args) throws Exception {
Option encodingOption = new Option("e", "blockEncoding", true, "Data block encoding; Default: FAST_DIFF");
encodingOption.setRequired(false);
options.addOption(encodingOption);
Option ratioOption = new Option("r", "selectionRatio", true, "Ratio of selected rows using essential column family");
ratioOption.setRequired(false);
options.addOption(ratioOption);
Option widthOption = new Option("w", "valueWidth", true, "Width of value for non-essential column family");
widthOption.setRequired(false);
options.addOption(widthOption);
CommandLineParser parser = new GnuParser();
CommandLine cmd = parser.parse(options, args);
if (args.length < 1) {
HelpFormatter formatter = new HelpFormatter();
formatter.printHelp("TestJoinedScanners", options, true);
}
if (cmd.hasOption("e")) {
blockEncoding = DataBlockEncoding.valueOf(cmd.getOptionValue("e"));
}
if (cmd.hasOption("r")) {
selectionRatio = Integer.parseInt(cmd.getOptionValue("r"));
}
if (cmd.hasOption("w")) {
valueWidth = Integer.parseInt(cmd.getOptionValue("w"));
}
// run the test
TestJoinedScanners test = new TestJoinedScanners();
test.testJoinedScanners();
}
use of org.apache.commons.cli.Option in project moco by dreamhead.
the class StartArgsParser method cert.
protected Option cert() {
Option option = new Option(null, "cert", true, "Cert password");
option.setType(String.class);
option.setRequired(false);
return option;
}
use of org.apache.commons.cli.Option in project moco by dreamhead.
the class ShutdownArgs method createShutdownOptions.
private static Options createShutdownOptions() {
Options options = new Options();
Option option = shutdownPortOption();
option.setRequired(true);
options.addOption(option);
return options;
}
Aggregations