我需要用Java编写一个简单的类似shell的应用程序。最好使用一个库来处理命令解析,以及处理标志、可选/必需参数等等...
如果有内置的TAB自动补全功能,那就更好了。
我需要用Java编写一个简单的类似shell的应用程序。最好使用一个库来处理命令解析,以及处理标志、可选/必需参数等等...
如果有内置的TAB自动补全功能,那就更好了。
cliche
:https://code.google.com/p/cliche/。非常简单,但足够强大,可以满足各种需求。 - Benj请查看JBoss Forge(https://docs.jboss.org/author/display/FORGE/Home)。
它是基于Java CDI插件的构建外壳,可以通过自定义插件进行扩展。 在我的情况下,我编写了一个基于Forge的GWT插件(https://github.com/xandrox/forge-gwtplugin)。
public class ExamplePlugin implements Plugin {
@Inject private ShellPrompt prompt;
@Command("run")
public void run(PipeOut out, @Option(name="value") final String arg){
out.println("Executed command with value: " + arg);
}
}