本文整理汇总了Java中org.kohsuke.args4j.CmdLineParser.parseArgument方法的典型用法代码示例。如果您正苦于以下问题:Java CmdLineParser.parseArgument方法的具体用法?Java CmdLineParser.parseArgument怎么用?Java CmdLineParser.parseArgument使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.kohsuke.args4j.CmdLineParser
的用法示例。
在下文中一共展示了CmdLineParser.parseArgument方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parse
import org.kohsuke.args4j.CmdLineParser; //导入方法依赖的package包/类
/** Parse the command line options.
* @param args the command line args as passed to the main method of the
* program.
* @return the parsed command line options or {@code null} if
* the program needs to exit. {@code null} will be returned
* if the command lines are wrong or the command line help
* was displayed.
*/
public static Params parse(String[] args) {
Params result = new Params();
CmdLineParser cmdLineParser = new CmdLineParser(result);
try {
if (log.isDebugEnabled()) {
log.debug("Args: {}", Arrays.toString(args));
}
cmdLineParser.parseArgument(args);
if (result.help) {
cmdLineParser.printUsage(System.err);
return null;
}
return result;
} catch (CmdLineException ex) {
log.warn("Error in parsing", ex);
System.err.println(ex.getMessage());
cmdLineParser.printUsage(System.err);
}
return null;
}
示例2: main
import org.kohsuke.args4j.CmdLineParser; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException {
Producer producer = new Producer();
CmdLineParser parser = new CmdLineParser(producer);
try {
parser.parseArgument(args);
} catch (CmdLineException ce) {
System.err.println(ce.getMessage());
System.err.println();
System.err.println(" Options are:");
parser.printUsage(System.err); // print the list of available options
System.err.println();
System.exit(0);
}
producer.run();
}
示例3: doMain
import org.kohsuke.args4j.CmdLineParser; //导入方法依赖的package包/类
private void doMain(final String[] arguments) throws IOException
{
final CmdLineParser parser = new CmdLineParser(this);
if (arguments.length < 1)
{
parser.printUsage(out);
System.exit(-1);
}
try
{
parser.parseArgument(arguments);
}
catch (CmdLineException clEx)
{
out.println("ERROR: Unable to parse command-line options: " + clEx);
}
out.println("The file '" + fileName + "' was provided and verbosity is set to '" + verbose + "'.");
}
示例4: doMain
import org.kohsuke.args4j.CmdLineParser; //导入方法依赖的package包/类
private void doMain(
String[] args) {
CmdLineParser parser = new CmdLineParser(this);
try {
parser.parseArgument(args);
ensureResultXmlDirectory();
generateDonutJsonFiles();
}catch (CmdLineException c){
System.err.println(c.getMessage());
System.err.println("usage: Main [options ...]");
parser.printUsage(System.err);
System.exit(1);
}catch (Exception e) {
System.err.println(e.getMessage());
System.exit(1);
}
}
示例5: doMain
import org.kohsuke.args4j.CmdLineParser; //导入方法依赖的package包/类
private final void doMain(String... args) throws Exception {
final ParserProperties properties = ParserProperties.defaults()
.withUsageWidth(80)
.withShowDefaults(true);
final CmdLineParser parser = new CmdLineParser(this, properties);
try {
parser.parseArgument(args);
final int enabledBoilers = (zlib_ ? 1:0) + (lzf_ ? 1:0) + (snappy_ ? 1:0);
if (compress_ == null && decompress_ == null) {
throw new IllegalArgumentException("Missing '--compress' or '--decompress' " +
"argument.");
} else if (compress_ != null && decompress_ != null) {
throw new IllegalArgumentException("Must specify only one of '--compress' or " +
"'--decompress' arguments.");
} else if (enabledBoilers > 1) {
throw new IllegalArgumentException("Can only specify one of --zlib, --lzf, or --snappy.");
} else if (enabledBoilers == 0) {
throw new IllegalArgumentException("Must specify at least one of --zlib, --lzf, or --snappy.");
}
run(); // Go!
} catch (Exception e) {
log.debug("Failed to start; see usage.", e);
parser.printUsage(System.err);
}
}
示例6: Exporter
import org.kohsuke.args4j.CmdLineParser; //导入方法依赖的package包/类
public Exporter(String[] args) {
final CmdLineParser parser = new CmdLineParser(this, ParserProperties.defaults().withUsageWidth(80));
try {
parser.parseArgument(args);
} catch (CmdLineException e) {
System.err.println(e.getMessage());
print_usage_and_exit_(parser);
/* UNREACHABLE */
}
// If help is requested, simply print that.
if (help) {
print_usage_and_exit_(parser);
/* UNREACHABLE */
}
// If there are no files, comlain with a non-zero exit code.
if (dir == null)
System.exit(EX_USAGE);
dirPath = FileSystems.getDefault().getPath(dir);
}
示例7: Verify
import org.kohsuke.args4j.CmdLineParser; //导入方法依赖的package包/类
/**
* Initialize the verifier, using command-line arguments.
* @param args The command-line arguments passed to the program.
*/
public Verify(String[] args) {
final CmdLineParser parser = new CmdLineParser(this, ParserProperties.defaults().withUsageWidth(80));
try {
parser.parseArgument(args);
} catch (CmdLineException e) {
System.err.println(e.getMessage());
print_usage_and_exit_(parser);
/* UNREACHABLE */
}
// If help is requested, simply print that.
if (help) {
print_usage_and_exit_(parser);
/* UNREACHABLE */
}
// If there are no files, comlain with a non-zero exit code.
if (files.isEmpty())
System.exit(EX_USAGE);
}
示例8: parseArguments
import org.kohsuke.args4j.CmdLineParser; //导入方法依赖的package包/类
private void parseArguments(String[] args) {
CmdLineParser parser = new CmdLineParser(this);
try {
parser.parseArgument(args);
} catch (CmdLineException e) {
// if there's a problem in the command line,
// you'll get this exception. this will report
// an error message.
System.err.println(e.getMessage());
System.err.println("java -jar reddit-history.jar [options...] arguments...");
// print the list of available options
parser.printUsage(System.err);
System.err.println();
System.exit(0);
return;
}
}
示例9: RhistMain
import org.kohsuke.args4j.CmdLineParser; //导入方法依赖的package包/类
/**
* Initialize the verifier, using command-line arguments.
*
* @param args The command-line arguments passed to the program.
*/
public RhistMain(String[] args) {
final CmdLineParser parser = new CmdLineParser(this, ParserProperties.defaults().withUsageWidth(80));
try {
parser.parseArgument(args);
} catch (CmdLineException e) {
System.err.println(e.getMessage());
print_usage_and_exit_(parser);
/* UNREACHABLE */
}
// If help is requested, simply print that.
if (help) {
print_usage_and_exit_(parser);
/* UNREACHABLE */
}
// If there are no files, comlain with a non-zero exit code.
if (dir == null)
System.exit(EX_USAGE);
path_ = FileSystems.getDefault().getPath(dir);
}
示例10: parseCommandLineArgumentsAndRun
import org.kohsuke.args4j.CmdLineParser; //导入方法依赖的package包/类
private static void parseCommandLineArgumentsAndRun(String[] args) {
CommandLineParameters parameters = new CommandLineParameters();
AmidstMetaData metadata = createMetadata();
CmdLineParser parser = new CmdLineParser(
parameters,
ParserProperties.defaults().withShowDefaults(false).withUsageWidth(120).withOptionSorter(null));
try {
parser.parseArgument(args);
run(parameters, metadata, parser);
} catch (CmdLineException e) {
System.out.println(metadata.getVersion().createLongVersionString());
System.err.println(e.getMessage());
parser.printUsage(System.out);
System.exit(2);
}
}
示例11: parseArguments
import org.kohsuke.args4j.CmdLineParser; //导入方法依赖的package包/类
private void parseArguments(String[] args) {
CmdLineParser parser = new CmdLineParser(this);
try {
parser.parseArgument(args);
} catch (CmdLineException e) {
// if there's a problem in the command line,
// you'll get this exception. this will report
// an error message.
System.err.println(e.getMessage());
System.err.println("java -jar torfiles.jar [options...] arguments...");
// print the list of available options
parser.printUsage(System.err);
System.err.println();
System.exit(0);
return;
}
}
示例12: main
import org.kohsuke.args4j.CmdLineParser; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException {
final MultiEntitySinkConfig config = new MultiEntitySinkConfig();
final CmdLineParser cmdLineParser = new CmdLineParser(config);
try {
cmdLineParser.parseArgument(args);
final OsmosisReader reader = new OsmosisReader(newInputStream(config.getSource()));
final MultiEntitySink sink = new MultiEntitySink(config);
sink.addObserver(new MultiEntitySinkObserver());
reader.setSink(sink);
reader.run();
} catch (CmdLineException e) {
System.out.println(e.getMessage());
System.out.print("Usage: java -jar osm-parquetizer.jar");
System.out.println();
cmdLineParser.printSingleLineUsage(System.out);
}
}
示例13: main
import org.kohsuke.args4j.CmdLineParser; //导入方法依赖的package包/类
public static void main(String[] args) throws ClassNotFoundException {
// https://martin-thoma.com/how-to-parse-command-line-arguments-in-java/
EBoardRender.Config config = new EBoardRender.Config();
CmdLineParser parser = new CmdLineParser( config );
try {
parser.parseArgument(args);
} catch (CmdLineException e) {
e.printStackTrace();
}
Configuration conf = Configuration.getInstance(config.getConfig());
String command = conf.getCommand().trim().toUpperCase();
CommandHandler commandHandler = conf.getCommandHandlerFactory().getCommandHandler(command);
commandHandler.execute(conf);
}
示例14: processArgs
import org.kohsuke.args4j.CmdLineParser; //导入方法依赖的package包/类
private void processArgs(String[] args) throws CmdLineException {
CmdLineParser parser = new CmdLineParser(this);
try {
parser.parseArgument(args);
if (arguments.isEmpty()
&& (pageDir == null || configFile == null || solrUrl == null)) {
throw new CmdLineException("Usage Error!");
}
} catch (CmdLineException e) {
System.err.println(e.getMessage());
System.err.println(USAGE);
parser.printUsage(System.err);
throw e;
}
}
示例15: FreebaseToolsRunner
import org.kohsuke.args4j.CmdLineParser; //导入方法依赖的package包/类
public FreebaseToolsRunner(String[] initArgs) {
// Use this to construct a tools instance with a set of command-line `initArgs',
// for example, `new FreebaseTools(new String[]{"--version"})'.
CmdLineParser parser = new CmdLineParser(this);
try {
parser.parseArgument(initArgs);
if (showUsage) {
System.err.println(versionString);
System.err.println("Usage:");
parser.printUsage(System.err);
System.exit(0);
}
} catch (CmdLineException e) {
System.err.println("ERROR: " + e.getMessage());
System.err.println("Usage:");
parser.printUsage(System.err);
System.exit(1);
}
}