本文整理汇总了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;
}
示例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);
}
示例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);
}
}
示例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();
}
}
示例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);
}
示例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();
}
}
}
示例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