当前位置: 首页>>代码示例>>Java>>正文


Java CmdLineParser.parseArgument方法代码示例

本文整理汇总了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;
}
 
开发者ID:1and1,项目名称:cli-skeleton,代码行数:32,代码来源:Params.java

示例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();
}
 
开发者ID:javaronok,项目名称:kafka-mgd-sample,代码行数:18,代码来源:Producer.java

示例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 + "'.");
}
 
开发者ID:dustinmarx,项目名称:java-cli-demos,代码行数:19,代码来源:Main.java

示例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);
    }
}
 
开发者ID:DonutReport,项目名称:donut-nunit-adapter,代码行数:20,代码来源:Main.java

示例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);
    }
}
 
开发者ID:markkolich,项目名称:boildown,代码行数:26,代码来源:Boil.java

示例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);
}
 
开发者ID:groupon,项目名称:monsoon,代码行数:23,代码来源:Exporter.java

示例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);
}
 
开发者ID:groupon,项目名称:monsoon,代码行数:25,代码来源:Verify.java

示例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;
    }
}
 
开发者ID:dessalines,项目名称:flowchat,代码行数:20,代码来源:ChatService.java

示例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);
}
 
开发者ID:groupon,项目名称:monsoon,代码行数:28,代码来源:RhistMain.java

示例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);
	}
}
 
开发者ID:toolbox4minecraft,项目名称:amidst,代码行数:17,代码来源:Amidst.java

示例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;
    }
}
 
开发者ID:dessalines,项目名称:torfiles,代码行数:20,代码来源:WebService.java

示例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);
    }
}
 
开发者ID:adrianulbona,项目名称:osm-parquetizer,代码行数:18,代码来源:App.java

示例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);
    }
 
开发者ID:eamonfoy,项目名称:trello-to-markdown,代码行数:18,代码来源:EBoardRender.java

示例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;
  }
}
 
开发者ID:USCDataScience,项目名称:PersonaExtraction,代码行数:17,代码来源:PersonaIndexer.java

示例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);
    }
}
 
开发者ID:isoboroff,项目名称:basekb-search,代码行数:20,代码来源:FreebaseToolsRunner.java


注:本文中的org.kohsuke.args4j.CmdLineParser.parseArgument方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。