是否有好的 Java 库可以帮助构建命令行应用程序?

发布于 2024-07-11 07:00:24 字数 1542 浏览 6 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(9

禾厶谷欠 2024-07-18 07:00:27

我使用过JSAP。 我发现它很稳定并且有据可查。

我不确定我是否理解“内置 TAB 完成”的意思。 能否详细说明一下。

I have used JSAP. I have found it to be stable and well documented.

I am not sure I understand what you mean by "built-in TAB completion". Can you elaborate.

提赋 2024-07-18 07:00:26

我使用 Apache Commons CLI 库 进行命令行参数解析。 它相当容易使用,并且有相当好的文档

您选择哪个库可能取决于您喜欢哪种样式的选项(“--gnu-style”或“-javac-style”)。

I've used the Apache Commons CLI library for command-line argument parsing. It's fairly easy to use and has reasonably good documentation.

Which library you choose probably comes down to which style of options you prefer ("--gnu-style" or "-javac-style").

放手` 2024-07-18 07:00:26

JLine 看起来很有帮助。

JLine 是一个用于处理控制台输入的 Java 库。 它的功能与 BSD editline 和 GNU readline 类似。 熟悉现代 shell(例如 bash 和 tcsh)的 readline/editline 功能的人会发现 JLine 的大多数命令编辑功能都很熟悉。

它的功能中确实列出了制表符补全功能。

JLine looks helpful.

JLine is a Java library for handling console input. It is similar in functionality to BSD editline and GNU readline. People familiar with the readline/editline capabilities for modern shells (such as bash and tcsh) will find most of the command editing features of JLine to be familiar.

And it does list tab completion in its features

陌上青苔 2024-07-18 07:00:26

当您正在寻找一个可以轻松开发交互式 shell 应用程序的库时,我建议您使用Cliche

As you're searching for a library that eases developing an interactive shell application, I'd suggest Cliche.

无人问我粥可暖 2024-07-18 07:00:26

在我们公司,我们使用 JewelCli,它使用带注释的 Java 接口定义以声明性方式描述命令行接口风格。

轻便且易于使用,我会推荐它。

In our company we are using JewelCli that uses an annotated Java interface definition to describe the Command Line Interface in a declarative style.

Light and simple to use, I'll recommend it.

故事灯 2024-07-18 07:00:26

我广泛使用了 Java 简单参数解析器。 它处理各种选项类型,具有精心设计的库(包括编写自定义解析器的选项),并在 JavaDocs 和 在线

我认为您对制表符完成的渴望将由 shell 而不是命令行解析库来处理。

I have used the Java Simple Argument Parser extensively. It handles all sorts of option types, has a well-designed and library (including the option to write custom parsers), and provides good documentation both in the JavaDocs and online.

I think your desire for tab completion would be taken care of by the shell rather than the command-line parsing library.

孤星 2024-07-18 07:00:26

我尝试了一些库,最终使用了 argparse4j。 这是 Python argparse 的一个非常好的 Java 端口。

I tried a few libraries and ended up using argparse4j. It's a really nice Java port of Python's argparse.

故事灯 2024-07-18 07:00:26

有一个用于命令行解析的 GNU getopt 库的 Java 端口。 对于命令编辑和 TAB 完成,有 JLine(正如 mmyers 已经推荐的那样)。

There is a Java port of GNU getopt library for command line parsing. For command editing and TAB completion there is JLine (as mmyers has already recommended).

半透明的墙 2024-07-18 07:00:26

--joopt-simple 也值得一看。

它“尝试遵循 POSIX getopt() 和 GNU getopt_long() 的命令行选项语法。”
它似乎有一些社区吸引力,尤其是 OpenJDK 选择的命令行解析库。

此外,正如 Brett 提到的,制表符补全通常由 shell 提供 - 您可以编写 shell 函数来提供所需的功能。

ps 很抱歉重复回答,但这个问题几乎与 Java 库相同解析命令行参数?

It's also worth looking at --jopt-simple.

It 'attempts to honor the command line option syntaxes of POSIX getopt() and GNU getopt_long().'
It seems to have some community traction, notably being the command line parsing lib of choice for the OpenJDK.

Also, as Brett mentioned, tab completion is typically provided by your shell - you would write shell functions to provide that desired functionality.

p.s. Sorry for the duplicate answer, but this question is almost identical to Java library for parsing command-line parameters?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文