use of org.kohsuke.args4j.CmdLineParser in project buck by facebook.
the class ArtifactConfig method fromCommandLineArgs.
public static ArtifactConfig fromCommandLineArgs(String[] args) throws CmdLineException, IOException {
CmdLineArgs parsedArgs = new CmdLineArgs();
CmdLineParser parser = new CmdLineParser(parsedArgs);
parser.parseArgument(args);
if (parsedArgs.showHelp) {
usage(parser);
}
ArtifactConfig artifactConfig;
// If the -config argument was specified, load a config from JSON.
if (parsedArgs.artifactConfigJson != null) {
ObjectMapper mapper = new ObjectMapper();
File jsonFile = new File(parsedArgs.artifactConfigJson);
artifactConfig = mapper.readValue(jsonFile, ArtifactConfig.class);
} else {
artifactConfig = new ArtifactConfig();
}
if (artifactConfig.buckRepoRoot == null && parsedArgs.buckRepoRoot == null) {
usage(parser);
}
artifactConfig.mergeCmdLineArgs(parsedArgs);
return artifactConfig;
}
use of org.kohsuke.args4j.CmdLineParser in project pinot by linkedin.
the class RawIndexBenchmark method main.
/**
* Main method for the class. Parses the command line arguments, and invokes the benchmark.
*
* @param args Command line arguments.
* @throws Exception
*/
public static void main(String[] args) throws Exception {
RawIndexBenchmark benchmark = new RawIndexBenchmark();
CmdLineParser parser = new CmdLineParser(benchmark);
parser.parseArgument(args);
benchmark.run();
}
use of org.kohsuke.args4j.CmdLineParser in project pinot by linkedin.
the class PinotAdministrator method execute.
public void execute(String[] args) throws Exception {
try {
CmdLineParser parser = new CmdLineParser(this);
parser.parseArgument(args);
if ((_subCommand == null) || _help) {
printUsage();
} else if (_subCommand.getHelp()) {
_subCommand.printUsage();
_status = true;
} else {
_status = _subCommand.execute();
}
} catch (CmdLineException e) {
LOGGER.error("Error: {}", e.getMessage());
} catch (Exception e) {
LOGGER.error("Exception caught: ", e);
}
}
use of org.kohsuke.args4j.CmdLineParser in project pinot by linkedin.
the class PinotToolLauncher method execute.
public void execute(String[] args) throws Exception {
try {
CmdLineParser parser = new CmdLineParser(this);
parser.parseArgument(args);
if ((_subCommand == null) || _help) {
printUsage();
} else if (_subCommand.getHelp()) {
_subCommand.printUsage();
} else {
_subCommand.execute();
}
} catch (CmdLineException e) {
LOGGER.error("Error: {}", e.getMessage());
} catch (Exception e) {
LOGGER.error("Exception caught: ", e);
}
}
use of org.kohsuke.args4j.CmdLineParser in project pinot by linkedin.
the class MoveReplicaGroup method main.
public static void main(String[] args) throws Exception {
MoveReplicaGroup mrg = new MoveReplicaGroup();
CmdLineParser parser = new CmdLineParser(mrg);
try {
parser.parseArgument(args);
} catch (CmdLineException e) {
LOGGER.error("Failed to parse arguments: {}", e);
parser.printUsage(System.err);
System.exit(1);
}
mrg.execute();
}
Aggregations