是否有支持在java中构建控制台应用程序的框架? 我知道Spring-Shell但是这会创建一个我不需要的shell。
例如,我想创建带注释的命令类,如...
@Command(name="c", desc="Copies files from source directory to target directory.")
public class MyCopyCommand {
@Argument(mandatory=true, desc="source directory")
private String sourceDirectory;
@Argument(mandatory=true, desc="target directory")
private String targetDirectory;
@Execute
public void copy() {
// copy files
}
}
并且一些Executor-Class应该处理给定的程序参数并调用适当的Command-Class。
有这样的Framwork吗?最好与Spring整合。
答案 0 :(得分:0)
有Apache Felix Gogo和it is extensible。该示例甚至使用与OP中相同的@Command
注释。
答案 1 :(得分:0)
现在我已经用Spring-Shell实现了它。如果使用命令调用程序,Spring-Shell不会打开shell。
./ myApp =>打开shell
./ myApp myCommand =>不打开外壳
适用于我的目的。