Java命令行程序构建工具airlift使用之分组(group)
来源:互联网 发布:coc各级墙升级数据 编辑:程序博客网 时间:2024/06/05 11:58
闲话少说,直接上代码:
package com.ilucky.druid.airlift.test2;import java.util.Arrays;import io.airlift.airline.Cli;import io.airlift.airline.Cli.CliBuilder;import io.airlift.airline.Help;import io.airlift.airline.ParseArgumentsUnexpectedException;/** * v1.0:20161115 * 组的概念. * 右击Run As - Run Configurations - Arguments - Program arguments * 输入: g1 G1MyCommand test, g1 G1MyCommand2 test, * 或g2 G2MyCommand test, 运行, 查看Console窗口. * @author Ilucky */public class MainTest { @SuppressWarnings("unchecked") public static void main(String[] args) { System.out.println("===> " + Arrays.asList(args)); CliBuilder<Runnable> builder = Cli.<Runnable>builder("MyCommand:Builder"); builder.withGroup("g1") .withDescription("g1:Description") .withDefaultCommand(Help.class) .withCommands(Help.class, G1MyCommand.class, G1MyCommand2.class); builder.withGroup("g2") .withDescription("g2:Description") .withDefaultCommand(Help.class) .withCommands(Help.class, G2MyCommand.class); Cli<Runnable> cliParser = builder.build(); try { cliParser.parse(args).run(); } catch (ParseArgumentsUnexpectedException e) { System.out.println("Invalid command:"+e.toString()); } }}/**输入: g1 G1MyCommand test, 结果:===> [g1, G1MyCommand, test]G1MyCommand=test输入: g1 G1MyCommand2 test, 结果:===> [g1, G1MyCommand2, test]G1MyCommand2=test输入: g2 G2MyCommand test, 结果:===> [g2, G2MyCommand, test]G2MyCommand=test*/
package com.ilucky.druid.airlift.test2;import io.airlift.airline.Arguments;import io.airlift.airline.Command;@Command(name="G1MyCommand",description="This is G1MyCommand")public class G1MyCommand implements Runnable { @Arguments private String command; @Override public void run() { System.out.println("G1MyCommand=" + command); }}
package com.ilucky.druid.airlift.test2;import io.airlift.airline.Arguments;import io.airlift.airline.Command;@Command(name="G1MyCommand2",description="This is G1MyCommand2")public class G1MyCommand2 implements Runnable { @Arguments private String command; @Override public void run() { System.out.println("G1MyCommand2=" + command); }}
package com.ilucky.druid.airlift.test2;import io.airlift.airline.Arguments;import io.airlift.airline.Command;@Command(name="G2MyCommand",description="This is G2MyCommand")public class G2MyCommand implements Runnable { @Arguments private String command; @Override public void run() { System.out.println("G2MyCommand=" + command); }}
阅读全文
0 0
- Java命令行程序构建工具airlift使用之分组(group)
- Java命令行程序构建工具airlift使用
- Java命令行程序构建工具-airline
- mongodb命令行group分组和java代码中group分组
- mongodb命令行group分组和java代码中group分组
- 熟练使用命令行工具开发Java程序
- 正则表达式之分组 group(java版)
- Java命令行工具使用
- GCD使用(五)分组操作(group)
- 使用Node.js构建命令行工具
- 使用命令行工具构建Maven项目
- 使用命令行工具构建ionic项目
- 使用Node.js构建命令行工具
- C#之LINQ基础 使用group将数据分组
- java:Mongodb 分组统计应用group的使用(含场景)
- 微信小程序 LeanCloud(二)命令行工具使用
- 使用命令行工具编译C#程序
- 使用命令行执行Java程序
- Java初学之代码篇<一>
- 动态代理
- 探究Angular依赖注入对象$injector
- iOS-YHAlertView(自定义AlertView,Swift版)
- QDU首届易途杯大赛-kk与cillyb的荣誉之战
- Java命令行程序构建工具airlift使用之分组(group)
- JS那些事儿(4)-对象
- javabean规范中要求实现Serializable接口,有什么作用?
- Spring MVC 使用SimpleUrlHandlerMapping做映射处理的简单用例
- 激光雷达学习笔记(二)数据读取和显示
- 用java实现栈的拓展—8进制的转换
- 深入Java内存区域
- test adasfadf
- 跨数据库查询(跨DB查询)并嵌套插入数据