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


Java JCommander.addCommand方法代码示例

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


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

示例1: 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

示例2: setupJCommanderTest

import com.beust.jcommander.JCommander; //导入方法依赖的package包/类
/**
 * Initializes JCommander and a {@link TestJCommandConfiguration} and adds it to the commands
 * JCommander listens to.
 */
@Before
public void setupJCommanderTest() {
   jCommander = new JCommander();
   sampleCommandConfiguration = new TestJCommandConfiguration();
   jCommander.addCommand(COMMAND_SET_ALGORITHMS, sampleCommandConfiguration);
}
 
开发者ID:Intelligent-Systems-Group,项目名称:jpl-framework,代码行数:11,代码来源:JCommanderTest.java

示例3: setupJCommanderTest

import com.beust.jcommander.JCommander; //导入方法依赖的package包/类
/**
 * Initializes the JCommander and a  TestJCommandConfiguration object and adds it to the commands
 * JCommander listens to.
 */
@Before
public void setupJCommanderTest() {
   jCommander = new JCommander();
   evaluateAlgorithmsCommandConfiguration = new EvaluateAlgorithmsCommandConfiguration();
   jCommander.addCommand(EVALUATE_ALGORITHM_COMMAND_LINE, evaluateAlgorithmsCommandConfiguration);
}
 
开发者ID:Intelligent-Systems-Group,项目名称:jpl-framework,代码行数:11,代码来源:JCommanderEvaluateAlgorithmsCommandTest.java

示例4: 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

示例5: main

import com.beust.jcommander.JCommander; //导入方法依赖的package包/类
public static void main(final String[] args) throws Exception {
    final Map<String, IWalleCommand> subCommandList = new HashMap<String, IWalleCommand>();
    subCommandList.put("show", new ShowCommand());
    subCommandList.put("rm", new RemoveCommand());
    subCommandList.put("put", new PutCommand());
    subCommandList.put("batch", new BatchCommand());
    subCommandList.put("batch2", new Batch2Command());

    final WalleCommandLine walleCommandLine = new WalleCommandLine();
    final JCommander commander = new JCommander(walleCommandLine);

    for (Map.Entry<String, IWalleCommand> commandEntry : subCommandList.entrySet()) {
        commander.addCommand(commandEntry.getKey(), commandEntry.getValue());
    }
    try {
        commander.parse(args);
    } catch (ParameterException e) {
        System.out.println(e.getMessage());
        commander.usage();
        System.exit(1);
        return;
    }

    walleCommandLine.parse(commander);

    final String parseCommand = commander.getParsedCommand();
    if (parseCommand != null) {
        subCommandList.get(parseCommand).parse();
    }
}
 
开发者ID:Meituan-Dianping,项目名称:walle,代码行数:31,代码来源:Main.java

示例6: CommandInterpreter

import com.beust.jcommander.JCommander; //导入方法依赖的package包/类
public CommandInterpreter(String[] args) throws IOException{
    Arrays.stream(args).forEach(a->System.out.println(a));
    commander = new JCommander(new CommandInterpreter());
    ExcelToHql eth = new ExcelToHql();
    commander.addCommand("eth", eth);
    Load l = new Load();
    commander.addCommand("load", l);
    RunBusinessLogic b = new RunBusinessLogic();
    commander.addCommand("hive", b);
    CompareActualToExpected c = new CompareActualToExpected();
    commander.addCommand("assert", c);
    Clean cl = new Clean();
    commander.addCommand("clean", cl);
    commander.parse(args);
}
 
开发者ID:gboleslavsky,项目名称:HiveUnit,代码行数:16,代码来源:CommandInterpreter.java

示例7: main

import com.beust.jcommander.JCommander; //导入方法依赖的package包/类
/**
 * Used for integration testing
 *
 * @param argv arguments provided match usage in the dockstore script (i.e. tool launch ...)
 */
public static void main(String[] argv) {
    CommandMain commandMain = new CommandMain();

    CommandAdd commandAdd = new CommandAdd();
    CommandPublish commandPublish = new CommandPublish();

    JCommander jc = new JCommander(commandMain);

    jc.addCommand("add", commandAdd);
    jc.addCommand("publish", commandPublish);

    jc.setProgramName("client");
    try {
        jc.parse(argv);
    } catch (MissingCommandException e) {
        LOGGER.warn(e.getMessage());
        jc.usage();
    }
    if (commandMain.help) {
        jc.usage();
    } else {
        String command = jc.getParsedCommand();
        if (command == null) {
            LOGGER.warn("Expecting 'publish' or 'add' command");
            jc.usage();
            return;
        }
        switch (command) {
        case "add":
            if (commandAdd.help) {
                jc.usage("add");
            } else {
                Add add = new Add(commandMain.config);
                add.handleAdd(commandAdd.dockerfile, commandAdd.descriptor, commandAdd.secondaryDescriptor, commandAdd.version);
            }
            break;
        case "publish":
            if (commandPublish.help) {
                jc.usage("publish");
            } else {
                Publish publish = new Publish(commandMain.config);
                publish.handlePublish(commandPublish.tool);
            }
            break;
        default:
            // JCommander should've caught this, this should never execute
            LOGGER.warn("Unknown command");
            jc.usage();
        }
    }
}
 
开发者ID:dockstore,项目名称:write_api_service,代码行数:57,代码来源:Client.java

示例8: afterPropertiesSet

import com.beust.jcommander.JCommander; //导入方法依赖的package包/类
@Override
public void afterPropertiesSet() throws Exception {
	String[] commandArgs = null;

	// check cli
	int commandPosition = Arrays.asList(args).indexOf(myBatisMigrationsProperties.getCliCommand());

	// found migration cli command?
	if (commandPosition >= 0) {
		// remove migration command from args
		commandArgs = Arrays.copyOfRange(args, commandPosition + 1, args.length);

		// show usage if migration called without arguments
		if (commandArgs.length == 0) {
			commandArgs = new String[]{"--help"};
		}
	}

	// check auto migration if no cli called
	if (commandArgs == null) {
		Collection<String> migrationCommand = myBatisMigrationsProperties.getMigrationCommand();
		commandArgs = migrationCommand.toArray(new String[migrationCommand.size()]);
	}

	if (commandArgs != null && commandArgs.length > 0) {
		Map<String, CommandBase> commands = new LinkedHashMap<>();

		commands.put("status", new CommandStatus(springMyBatisMigrations));
		commands.put("bootstrap", new CommandBootstrap(springMyBatisMigrations));
		commands.put("up", new CommandUp(springMyBatisMigrations));
		commands.put("pending", new CommandPending(springMyBatisMigrations));
		commands.put("version", new CommandVersion(springMyBatisMigrations));
		commands.put("down", new CommandDown(springMyBatisMigrations));

		CommandMain commandMain = new CommandMain();
		JCommander jCommander = new JCommander(commandMain);

		for (Entry<String, CommandBase> command : commands.entrySet()) {
			jCommander.addCommand(command.getKey(), command.getValue());
		}

		jCommander.parse(commandArgs);

		if (commandMain.isHelp()) {
			jCommander.usage();
			if (commandMain.isExit()) {
				exit();
			}
		}

		// action!
		commands.get(jCommander.getParsedCommand()).operate();

		if (commandMain.isExit()) {
			exit();
		}
	}
}
 
开发者ID:Bessonov,项目名称:mybatis-migrations-spring-boot-autoconfigure,代码行数:59,代码来源:MyBatisMigrationsCliHandler.java


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