Are there good Java libraries that facilitate building command-line applications? [closed]

妖精的绣舞 提交于 2019-11-28 16:31:16
Kevin ORourke

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").

Michael Myers

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

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

Have a look at arg4j.

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.

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.

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).

Ivar

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?

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.

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!