當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。