groovy-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Remko Popma <remko.po...@gmail.com>
Subject Re: next generation CliBuilder?
Date Wed, 21 Mar 2018 10:30:54 GMT
On Wed, Mar 21, 2018 at 5:23 PM, Jochen Theodorou <blackdrag@gmx.org> wrote:

>
>
> Am 21.03.2018 um 02:11 schrieb Paul King:
>
>> Picocli has always looked like a nice alternative. It wasn't an option
>> for me before it had the api but picocli 3 seems to have that covered.
>>
>
> can you refresh my memory about the position of JCommander in this? I see
> some overlap. And if we go with Picoli, we should probably explain the
> people in what case they should use what and how.
>
> Fair question. What distinguishes picocli from JCommander (and many other
CLI libraries):

   - JCommander has an annotations API, while picocli has both an
   annotations and a programmatic API
   <https://github.com/remkop/picocli/wiki/Programmatic-API>.
   The programmatic API is needed to support the dynamic features of
   CliBuilder.
   - picocli has easily customized
   <http://picocli.info/index.html#_usage_help> usage help with ANSI colors
   <http://picocli.info/#_ansi_colors_and_styles>
   - picocli-based apps and scripts can have command line autocompletion
   <http://picocli.info/autocomplete.html> in bash and zsh
   - picocli offers tight integration for Groovy scripts via the
   @PicocliScript annotation and AST transformation (see the Groovy Scripts
   on Steroids
   <http://picocli.info/picocli-2.0-groovy-scripts-on-steroids.html> post)
   - in picocli, both options and positional parameters can be strongly
   typed.  JCommander has strongly typed options, but positional parameters is
   an untyped list of strings.
   - picocli supports clustered short options
   <http://picocli.info/#_short_options>, so you can say <command>
   -xvfInputFile as well as <command> -x -v -f=InputFile. JCommander only
   supports the latter AFAIK.
   - picocli has a range-based arity model that allows a minimum, maximum
   and variable number of parameters, e.g, "1..*", "3..5". With JCommander
   one needs to choose between minimum arity or variable arity, and with
   variable arity one cannot have strong typing
   <http://jcommander.org/#_variable_arities> - Strings only.
   - picocli has convenience APIs
   <http://picocli.info/index.html#_less_boilerplate> that reduce the
   boilerplate code for command line applications to a single line of code


Picocli and JCommander both have:

   - quality documentation
   - support for subcommands
   - support for multi-value options, splitting an argument into multiple
   values, and map-like options (e.g., -Dkey=value)


JCommander features not in picocli (but on the todo list):

   - internationalization
   - support for suppressing password echo to the console
   - support for case-insensitive and abbreviated options


For more details, this CLI library comparison
<https://github.com/remkop/picocli/wiki/CLI-Comparison> page may be useful.
Dustin Marx‘s article series on command line interfaces, especially the summary
post
<http://marxsoftware.blogspot.jp/2017/11/java-cmd-line-observations.html>,
may also be of interest (although it covers an old version of picocli -
0.9.7).

Remko


> bye Jochen
>

Mime
View raw message