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


Java CmdLineException类代码示例

本文整理汇总了Java中org.kohsuke.args4j.CmdLineException的典型用法代码示例。如果您正苦于以下问题:Java CmdLineException类的具体用法?Java CmdLineException怎么用?Java CmdLineException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


CmdLineException类属于org.kohsuke.args4j包,在下文中一共展示了CmdLineException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: init

import org.kohsuke.args4j.CmdLineException; //导入依赖的package包/类
protected void init(String[] args) {
    try {
        parser.parseArgument(args);
    } catch (CmdLineException e) {
        System.err.println(e.getMessage());
        parser.printUsage(System.err);
        System.exit(1);
    }
    if (help) {
        parser.printUsage(System.err);
        System.exit(1);
    }
    if (!AuthScheme.NO_AUTH.equals(authScheme)) {
        if (keyStorePath == null) {
            System.err.println("keyStorePath is required when " +
                               "authScheme is " + authScheme);
            parser.printUsage(System.err);
            System.exit(1);
        }
        if (keyStorePassword == null) {
            Console con = System.console();
            char[] password = con.readPassword("Enter key store password: ");
            keyStorePassword = new String(password);
        }
    }
}
 
开发者ID:zhenshengcai,项目名称:floodlight-hardware,代码行数:27,代码来源:AuthTool.java

示例2: init

import org.kohsuke.args4j.CmdLineException; //导入依赖的package包/类
protected void init(String[] args) {
    try {
        parser.parseArgument(args);
    } catch (CmdLineException e) {
        System.err.println(e.getMessage());
        parser.printUsage(System.err);
        System.exit(1);
    }
    if (help) {
        parser.printUsage(System.err);
        System.exit(1);
    }
    if (!AuthScheme.NO_AUTH.equals(authScheme)) {
        if (keyStorePath == null) {
            System.err.println("keyStorePath is required when " + 
                               "authScheme is " + authScheme);
            parser.printUsage(System.err);
            System.exit(1);
        }
        if (keyStorePassword == null) {
            Console con = System.console();
            char[] password = con.readPassword("Enter key store password: ");
            keyStorePassword = new String(password);
        }
    }
}
 
开发者ID:sammyyx,项目名称:ACAMPController,代码行数:27,代码来源:AuthTool.java

示例3: invalidJsonForDiscoveryFilter

import org.kohsuke.args4j.CmdLineException; //导入依赖的package包/类
@Test
public void invalidJsonForDiscoveryFilter() throws CmdLineException, ConfigurationException {
    OFEventWFMTopology manager = new OFEventWFMTopology(makeLaunchEnvironment());
    TopologyConfig config = manager.getConfig();
    OFELinkBolt bolt = new OFELinkBolt(config);

    TopologyContext context = Mockito.mock(TopologyContext.class);

    Mockito.when(context.getComponentId(TASK_ID_BOLT))
            .thenReturn(COMPONENT_ID_SOURCE);
    Mockito.when(context.getComponentOutputFields(COMPONENT_ID_SOURCE, STREAM_ID_INPUT))
            .thenReturn(KafkaMessage.FORMAT);

    OutputCollectorMock outputDelegate = Mockito.spy(new OutputCollectorMock());
    OutputCollector output = new OutputCollector(outputDelegate);

    bolt.prepare(stormConfig(), context, output);
    bolt.initState(new InMemoryKeyValueState<>());

    Tuple tuple = new TupleImpl(context, new Values("{\"corrupted-json"), TASK_ID_BOLT, STREAM_ID_INPUT);
    bolt.doWork(tuple);

    Mockito.verify(outputDelegate).ack(tuple);
}
 
开发者ID:telstra,项目名称:open-kilda,代码行数:25,代码来源:OFELinkBoltTest.java

示例4: create

import org.kohsuke.args4j.CmdLineException; //导入依赖的package包/类
/**
 * Parse the CLI arguments and return the populated parameters structure.
 *
 * @param args the CLI arguments
 * @return the parsed parameters, or null if failed
 * @throws org.kohsuke.args4j.CmdLineException if cmd line is malformed
 */
public static CLI create (final String... args)
        throws CmdLineException
{
    logger.info("CLI args: {}", Arrays.toString(args));

    CLI cli = new CLI();

    final CmdLineParser parser = new CmdLineParser(cli);

    parser.parseArgument(args);

    if (args.length == 0) {
        cli.help = true;
    }

    if (cli.help) {
        printUsage(parser);
    }

    return cli;
}
 
开发者ID:Audiveris,项目名称:omr-dataset-tools,代码行数:29,代码来源:CLI.java

示例5: main

import org.kohsuke.args4j.CmdLineException; //导入依赖的package包/类
public static void main(final String[] args) {
    try {
        final MainArgs mainArgs = new MainArgs();

        new CmdLineParser(mainArgs).parseArgument(args);

        if (mainArgs.isHelp()) {
            printUsage();
        } else if (mainArgs.isVersion()) {
            printVersion();
        } else {
            Guice.createInjector(new EndPointHealthModule())
                    .getInstance(Main.class).run(mainArgs);
        }
    } catch (final CmdLineException e) {
        System.err.println(e.getMessage());
        printUsage();
    }
}
 
开发者ID:spypunk,项目名称:endpoint-health,代码行数:20,代码来源:Main.java

示例6: main

import org.kohsuke.args4j.CmdLineException; //导入依赖的package包/类
public static void main(String[] args) throws IOException {
    Consumer consumer = new Consumer();
    CmdLineParser parser = new CmdLineParser(consumer);

    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);
    }

    consumer.run();
}
 
开发者ID:javaronok,项目名称:kafka-mgd-sample,代码行数:18,代码来源:Consumer.java

示例7: main

import org.kohsuke.args4j.CmdLineException; //导入依赖的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

示例8: doMain

import org.kohsuke.args4j.CmdLineException; //导入依赖的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

示例9: main

import org.kohsuke.args4j.CmdLineException; //导入依赖的package包/类
/**
 * @return success value
 */
public static boolean main(String[] args)
        throws IOException, InterruptedException, URISyntaxException {
    PrintWriter writer = new PrintWriter(System.out, true);
    CliArgs arguments = new CliArgs();
    try {
        if (!arguments.parse(writer, args)) {
            return true;
        }
        if(arguments.isModeParse()) {
            parse(arguments);
            return true;
        } else {
            return diff(writer, arguments);
        }
    } catch (CmdLineException | NotAllowedObjectException ex) {
        System.err.println(ex.getLocalizedMessage());
        return false;
    }
}
 
开发者ID:pgcodekeeper,项目名称:pgcodekeeper,代码行数:23,代码来源:Main.java

示例10: parse

import org.kohsuke.args4j.CmdLineException; //导入依赖的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

示例11: doMain

import org.kohsuke.args4j.CmdLineException; //导入依赖的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

示例12: getParameters

import org.kohsuke.args4j.CmdLineException; //导入依赖的package包/类
/**
 * Parse the CLI arguments and return the populated parameters structure.
 *
 * @param args the CLI arguments
 * @return the parsed parameters, or null if failed
 * @throws org.kohsuke.args4j.CmdLineException
 */
public Parameters getParameters (final String... args)
        throws CmdLineException
{
    logger.info("CLI args: {}", Arrays.toString(args));
    actualArgs = args;

    parser.parseArgument(args);

    if (logger.isDebugEnabled()) {
        new Dumping().dump(params);
    }

    checkParams();

    return params;
}
 
开发者ID:Audiveris,项目名称:audiveris,代码行数:24,代码来源:CLI.java

示例13: parseArguments

import org.kohsuke.args4j.CmdLineException; //导入依赖的package包/类
@Override
public int parseArguments (org.kohsuke.args4j.spi.Parameters params)
        throws CmdLineException
{
    String className = params.getParameter(0).trim();

    if (!className.isEmpty()) {
        try {
            Class runClass = Class.forName(className);
            FieldSetter fs = setter.asFieldSetter();
            fs.addValue(runClass);
        } catch (Throwable ex) {
            throw new CmdLineException(owner, ex);
        }
    }

    return 1;
}
 
开发者ID:Audiveris,项目名称:audiveris,代码行数:19,代码来源:CLI.java

示例14: testRunError

import org.kohsuke.args4j.CmdLineException; //导入依赖的package包/类
@Test
public void testRunError ()
        throws Exception
{
    System.out.println("\n+++ testRunError");

    String[] args = new String[]{"-run", "fooBar"};

    try {
        CLI.Parameters params = instance.getParameters(args);

        fail();
    } catch (CmdLineException ex) {
        System.out.println(ex.getMessage());
        System.out.println(ex.getLocalizedMessage());
        assertTrue(ex.getMessage().contains("java.lang.ClassNotFoundException"));
    }
}
 
开发者ID:Audiveris,项目名称:audiveris,代码行数:19,代码来源:CLITest.java

示例15: testStepEmpty

import org.kohsuke.args4j.CmdLineException; //导入依赖的package包/类
@Test
public void testStepEmpty ()
        throws Exception
{
    System.out.println("\n+++ testStepEmpty");

    String[] args = new String[]{"-step"};

    try {
        CLI.Parameters params = instance.getParameters(args);

        fail();
    } catch (CmdLineException ex) {
        System.out.println(ex.getMessage());
        System.out.println(ex.getLocalizedMessage());
        assertTrue(ex.getMessage().contains("-step"));
    }
}
 
开发者ID:Audiveris,项目名称:audiveris,代码行数:19,代码来源:CLITest.java


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