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


Java JCommander.setProgramName方法代码示例

本文整理汇总了Java中com.beust.jcommander.JCommander.setProgramName方法的典型用法代码示例。如果您正苦于以下问题:Java JCommander.setProgramName方法的具体用法?Java JCommander.setProgramName怎么用?Java JCommander.setProgramName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.beust.jcommander.JCommander的用法示例。


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

示例1: parse

import com.beust.jcommander.JCommander; //导入方法依赖的package包/类
/**
 * Parses command line arguments and populates this command line instance.
 * <p>
 * If the command line arguments include the "help" argument, or if the
 * arguments have incorrect values or order, then usage information is
 * printed to {@link System#out} and the program terminates.
 *
 * @param args
 *            the command line arguments
 * @return an instance of the parsed arguments object
 */
public Arguments parse(String[] args) {

    JCommander jCommander = new JCommander(this);
    jCommander.setProgramName("jsonschema2pojo");

    try {
        jCommander.parse(args);

        if (this.showHelp) {
            jCommander.usage();
            exit(EXIT_OKAY);
        }
    } catch (ParameterException e) {
        System.err.println(e.getMessage());
        jCommander.usage();
        exit(EXIT_ERROR);
    }

    return this;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:32,代码来源:Arguments.java

示例2: VerbSenseArgumentCounter

import com.beust.jcommander.JCommander; //导入方法依赖的package包/类
private VerbSenseArgumentCounter(String... args) {
    JCommander cmd = new JCommander(this);
    cmd.setProgramName(this.getClass().getSimpleName());
    try {
        if (args.length == 0) {
            cmd.usage();
            System.exit(0);
        }
        cmd.parse(args);
    } catch (ParameterException e) {
        System.err.println(e.getMessage());
        cmd.usage();
        System.exit(1);
    }
    initializeDb();
    initializeAnnotator();
    validateDir();
}
 
开发者ID:clearwsd,项目名称:clearwsd,代码行数:19,代码来源:VerbSenseArgumentCounter.java

示例3: init

import com.beust.jcommander.JCommander; //导入方法依赖的package包/类
@Override
public synchronized void init(DaemonContext context) {
    if (state != State.NONE) {
        throw new IllegalStateException("initialized already");
    }

    final JCommander commander = new JCommander(this);
    commander.setProgramName(getClass().getName());
    commander.parse(context.getArguments());

    if (help != null && help) {
        commander.usage();
        final DaemonController controller = context.getController();
        if (controller != null) {
            controller.fail();
        }
        return;
    }

    state = State.INITIALIZED;
}
 
开发者ID:line,项目名称:centraldogma,代码行数:22,代码来源:Main.java

示例4: Commander

import com.beust.jcommander.JCommander; //导入方法依赖的package包/类
public Commander(Plugin plugin) {
  template = new CommandTemplate();
  jcommander = new JCommander(template);
  jcommander.setProgramName("spellcastr");
  bind = new CommandBind();
  jcommander.addCommand("bind", bind);
  create = new CommandCreate();
  jcommander.addCommand("create", create);
  setLore = new CommandSetLore();
  jcommander.addCommand("lore", setLore);
  setItem = new CommandSetItem();
  jcommander.addCommand("item", setItem);
  craft = new CommandCraft();
  jcommander.addCommand("craft", craft);
  setType = new CommandSetType();
  jcommander.addCommand("type", setType);
  setOption = new CommandSetOption();
  jcommander.addCommand("option", setOption);
  help = new CommandHelp();
  jcommander.addCommand("help", help);

  this.plugin = plugin;
}
 
开发者ID:NoobDoesMC,项目名称:SpellCastr,代码行数:24,代码来源:Commander.java

示例5: WordSenseCLI

import com.beust.jcommander.JCommander; //导入方法依赖的package包/类
WordSenseCLI(String[] args) {
    cmd = new JCommander(this);
    cmd.setProgramName(WordSenseCLI.class.getSimpleName());
    try {
        cmd.parse(args);
        if (help || args.length == 0) {
            System.out.println(helpMessage);
            cmd.usage();
            System.exit(0);
        }
    } catch (ParameterException e) {
        System.err.println(e.getMessage());
        cmd.usage();
        System.exit(1);
    }
}
 
开发者ID:clearwsd,项目名称:clearwsd,代码行数:17,代码来源:WordSenseCLI.java

示例6: main

import com.beust.jcommander.JCommander; //导入方法依赖的package包/类
public static void main(String[] args) {
    Injector injector = Guice.createInjector(new MavenModule(), new MavenCommandOptionsModule(), new XmlModule());
    OptionalArgs optionalArgs = injector.getInstance(OptionalArgs.class);
    JCommander jCommander = JCommander.newBuilder().addObject(optionalArgs).build();
    jCommander.setProgramName("mvnUploader");
    jCommander.parse(args);

    if (optionalArgs.isHelp()){
        jCommander.usage();
    } else {
        logger.info("Welcome To Maven Artifacts Uploader");
        Uploader uploader = injector.getInstance(Uploader.class);
        uploader.uploadToRepository(Paths.get(optionalArgs.getPathToArtifacts()));
        logger.info("Done uploading all the artifacts!");
    }
}
 
开发者ID:ronbadur,项目名称:maven-artifacts-uploader,代码行数:17,代码来源:Main.java

示例7: main

import com.beust.jcommander.JCommander; //导入方法依赖的package包/类
public static void main(final String[] args) {
	final Options options = new Options();
	final JCommander jCommander = JCommander.newBuilder().addObject(options).build();
	jCommander.setProgramName(PROGRAM_NAME);
	jCommander.parse(args);
	if (options.isHelp()) {
		jCommander.usage();
	} else {
		new Main(options).execute();
	}
}
 
开发者ID:SoerenHenning,项目名称:RadarGun,代码行数:12,代码来源:Main.java

示例8: main

import com.beust.jcommander.JCommander; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    CommandArgs cmdArgs = new CommandArgs();
    JCommander cmdParser = new JCommander(cmdArgs);
    try {
        cmdParser.setProgramName(GreetingAuthzClient.class.getName());
        cmdParser.parse(args);
    } catch (ParameterException e) {
        StringBuilder info = new StringBuilder("Specifiy the name of the application endpoint with --app\n");
        cmdParser.usage(info);
        System.err.printf(info.toString());
        System.exit(1);
    }
    // Handle outputCurlScript
    if(cmdArgs.outputCurlScript != null) {
        InputStream scriptStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("token_req_template.sh");
        Path path = FileSystems.getDefault().getPath(cmdArgs.outputCurlScript);
        Files.copy(scriptStream, path, StandardCopyOption.REPLACE_EXISTING);
        scriptStream.close();
        System.out.printf("Wrote script to: %s\n", path.toFile().getAbsolutePath());
        System.exit(0);
    }

    GreetingAuthzClient client = new GreetingAuthzClient();
    client.init(cmdArgs);
    System.out.printf("\nRequesting greeting...\n");
    Greeting greeting = client.getGreeting(cmdArgs.app, cmdArgs.from);
    System.out.printf("%s\n", greeting);
}
 
开发者ID:obsidian-toaster-quickstarts,项目名称:redhat-sso,代码行数:29,代码来源:GreetingAuthzClient.java

示例9: main

import com.beust.jcommander.JCommander; //导入方法依赖的package包/类
public static void main(String[] args) {
    ShotgunWSD shotgunWSD = new ShotgunWSD();

    try {
        new JCommander(shotgunWSD, args);
        shotgunWSD.run();
    } catch(ParameterException e) {
        String[] helpArgs = {"--help"};
        JCommander jCommander = new JCommander(shotgunWSD, helpArgs);
        jCommander.setProgramName("ShotgunWSD");
        jCommander.usage();
    }
}
 
开发者ID:butnaruandrei,项目名称:ShotgunWSD,代码行数:14,代码来源:ShotgunWSD.java

示例10: createCommander

import com.beust.jcommander.JCommander; //导入方法依赖的package包/类
private static JCommander createCommander(CommandContainer commandContainer, String[] args) {
    JCommander.Builder builder = JCommander.newBuilder();
    for (String operation : commandContainer.getAllCommands()) {
        CommandContainer.Command command = commandContainer.getCommand(operation);
        builder.addCommand(operation, command);
    }
    JCommander commander = builder.build();
    commander.setProgramName("stf");
    commander.setCaseSensitiveOptions(false);
    commander.parseWithoutValidation(args);
    return commander;
}
 
开发者ID:e13mort,项目名称:stf-console-client,代码行数:13,代码来源:StfCommander.java

示例11: main

import com.beust.jcommander.JCommander; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {

    ConversationUtility conversationCmd = new ConversationUtility();
    JCommander jCommander = new JCommander(conversationCmd);

    jCommander.setProgramName("Watson Conversation Globalization");
    jCommander.addCommand("help", new HelpCmd());

    jCommander.addCommand("WCS_To_GP", new WCS_To_GP(), "wcs_to_gp");
    jCommander.addCommand("GP_To_WCS", new GP_To_WCS(), "gp_to_wcs");

    try {
      jCommander.parse(args);
      String parsedCommand = jCommander.getParsedCommand();
      System.out.println(parsedCommand);
      if (parsedCommand == null || parsedCommand.equalsIgnoreCase("help")) {
        jCommander.usage();
      } else {
        BaseUtility parsedCmd = (BaseUtility) jCommander.getCommands().get(parsedCommand).getObjects().get(0);
        parsedCmd.execute();
      }
    } catch (ParameterException e) {
      System.err.println(e.getMessage());
      jCommander.usage();
      System.exit(1);
    }
  }
 
开发者ID:IBM-Cloud,项目名称:gp-watson-conversation,代码行数:28,代码来源:ConversationUtility.java

示例12: printUsageAndExit

import com.beust.jcommander.JCommander; //导入方法依赖的package包/类
void printUsageAndExit(int exitCode, CliArguments cliArguments) {
    StringBuilder out = new StringBuilder();

    JCommander jCommander = new JCommander(cliArguments);
    jCommander.setProgramName("java -jar " + jarName());
    jCommander.usage(out);
    System.err.println(out);
    System.exit(exitCode);
}
 
开发者ID:gocd,项目名称:gocd-filebased-authentication-plugin,代码行数:10,代码来源:PasswordGenerator.java

示例13: parseCommandLine

import com.beust.jcommander.JCommander; //导入方法依赖的package包/类
private void parseCommandLine(String [] args) {
	JCommander cmd = new JCommander(this, args);
	cmd.setProgramName(COMMAND_NAME);

	if(help) {
		cmd.usage();
		System.exit(0);
	}
}
 
开发者ID:matthiaszimmermann,项目名称:bitcoin-paper-wallet,代码行数:10,代码来源:Application.java

示例14: parse

import com.beust.jcommander.JCommander; //导入方法依赖的package包/类
public static Options parse(String[] cliArgs) {
  Options args = new Options();
  JCommander jc = JCommander.newBuilder()
    .addObject(args)
    .build();
  jc.parse(cliArgs);
  if(args.help){
    jc.setProgramName("dremio-admin clean");
    jc.usage();
  }
  return args;
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:13,代码来源:Clean.java

示例15: OntoNotesConverter

import com.beust.jcommander.JCommander; //导入方法依赖的package包/类
private OntoNotesConverter(String... args) {
    JCommander cmd = new JCommander(this);
    cmd.setProgramName(this.getClass().getSimpleName());
    try {
        cmd.parse(args);
    } catch (ParameterException e) {
        System.err.println(e.getMessage());
        cmd.usage();
        System.exit(1);
    }
}
 
开发者ID:clearwsd,项目名称:clearwsd,代码行数:12,代码来源:OntoNotesConverter.java


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