【问题标题】:Are there good Java libraries that facilitate building interactive shell-style applications?有没有很好的 Java 库可以帮助构建交互式 shell 风格的应用程序?
【发布时间】:2010-10-06 00:07:40
【问题描述】:

我需要用 Java 编写一个简单的 shell 风格的应用程序。使用一个负责解析命令并负责标志和可选/强制参数之类的库会很好......

具有内置 TAB 补全功能的东西会特别棒。

【问题讨论】:

  • bill the lizard 不正确...它不是完全重复...除非我弄错了,否则 shell 样式和命令行应用程序之间存在差异。

标签: java


【解决方案1】:

您可以使用JLine 进行编辑,使用Apache Commons CLI 进行命令行解析。

【讨论】:

【解决方案2】:

【讨论】:

  • 这是积极维护的吗?该网站没有任何发布日期,并且版本 2 的文档尚不可用。
  • 最近,他们说它最终会成为 J2SE 版本的一部分,所以我会说这应该是真正的答案。
【解决方案3】:

比起 Apache Commons CLI,我更喜欢 JewelCLIargs4j

有几个 java CLI 选项解析器 here 的一个很好的综述,虽然有点煽动性。

【讨论】:

    【解决方案4】:

    查看 JBoss Forge (https://docs.jboss.org/author/display/FORGE/Home)。

    它是一个基于 Java CDI 插件的构建外壳,并且可以通过自定义插件进行扩展。 我的情况是,我编写了一个基于 Forge (https://github.com/xandrox/forge-gwtplugin) 的 GWT 插件。

    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);
        }
    }  
    

    【讨论】:

      猜你喜欢
      • 2012-12-14
      • 2011-10-26
      • 2011-04-16
      • 2011-08-01
      • 2018-12-26
      • 1970-01-01
      • 2010-09-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多