Questions tagged [picocli]

Picocli is a command line parsing library for Java and other JVM languages. Distinguishing features: provides both a programmatic and an annotation API, usage help with ANSI colors, autocompletion on supported platforms and strong support for nested subcommands. Designed to optionally be included as source to avoid adding dependencies.

Picocli is an open-source library for creating command line applications in Java and other JVM languages with a minimum amount of code. Distinguishing features: provides both a programmatic and an annotation API, usage help with ANSI colors, autocompletion on supported platforms, nested subcommands (to any depth) and strongly typed options as well as positional parameters. Designed to optionally be included as source to avoid adding dependencies.

How to ask

If you are using or considering Picocli and your question is related to it, then you should add this tag. You should explain what you intend to achieve, how you tried to achieve it, what the actual behavior was and how that is different from your expectations.

Picocli Reference Documentation

Useful links

136 questions
2
votes
1 answer

Parsing picocli-based CLI usage output into structured data

I have a set of picocli-based applications that I'd like to parse the usage output into structured data. I've written three different output parsers so far and I'm not happy with any of them (fragility, complexity, difficulty in extending, etc.).…
Jan Nielsen
  • 10,892
  • 14
  • 65
  • 119
2
votes
1 answer

Two exclusive OptionGroup with Apache Commons CLI

I am building a command-line Java application and I have a problem with parsing the command line parameters with Apache Commons CLI. I am trying to cover my scenario where I need to have two exclusive command-line param groups with long (--abc) and…
2
votes
1 answer

Parsing multiple picocli (sub-)commands and a shell

How do I build a Spring Boot 2.3 multi-command CLI application that can be run with single command, an @script, and interactively in picocli? It should behave like this: manager -u -p [list|create|delete] # run and exit manager -u…
Jan Nielsen
  • 10,892
  • 14
  • 65
  • 119
2
votes
1 answer

How to improve command performance at runtime?

I have a library with an internal command line that uses picocli 3.9.6. One of these commands is the log command, which works like most loggers, taking a log level and message, and several other options. It gets called a lot in some applications…
marinier
  • 387
  • 3
  • 13
2
votes
1 answer

Using Picocli, how do I require a positional argument and then optional arguments depending on the value of the positional argument

I have a situation where I need to have three mandatory arguments (field1, field2 and field3. I then want the user to enter a command name (mandatory, values can be create, list, etc). The command name must be entered, and must be singular (only one…
Mark
  • 2,058
  • 2
  • 35
  • 64
2
votes
1 answer

picocli example showing the usage of multiple commands

ive got some code that works very well with picocli: @Command(name = "parse", sortOptions = false, description = "parse input files and write to database") class CommandLineArgumentParser { @Option(names = { "-h", "--help" }, usageHelp = true,…
James Baker
  • 107
  • 2
  • 11
2
votes
1 answer

Interoperability between Injections in Picocli commands and micronaut

Defining an @Singleton bean in Micronaut does not @Inject the same instance into Picocli commands. Micronaut offers an integration with Picocli. What is essential done, it seems, is that from the Picocli command, one can start an EmbeddedServer of…
38leinad
  • 196
  • 2
  • 11
2
votes
1 answer

display options for subcommands using PicoCLI

I am using PicoCLI v4.0.0-beta-1b. I am using different subcommands linked from a parent command. The parent command's optional parameters get displayed when I launch the CLI but not for the subcommands. The subcommands only appears underneath…
ali haider
  • 19,175
  • 17
  • 80
  • 149
2
votes
1 answer

Splitting a command in PicoCLI

I'm using picocli to implement a cli tool and I've got a command which looks like the following. mainCommand subCommand : parameter3 The question I have is how to map the parameter and parameter2 as picoCli parameters using…
Imesh Chandrasiri
  • 5,558
  • 15
  • 60
  • 103
2
votes
1 answer

Can picocli subcommands have options with the same name?

I have a program that executes different types of statistical analysis. I would like to define a subcommand for each type of analysis. The parent command would be the main entry point into the program. I get an error message that says "option should…
meyerjp3
  • 197
  • 1
  • 3
  • 16
2
votes
2 answers

Sbt task for picocli graalvm reflection generation?

In picocli they give examples on how to generate GraalVM reflection configurations during the build for Maven and Gradle. Gradle example configurations { generateConfig } dependencies { compile 'info.picocli:picocli:3.9.3' generateConfig…
kronolynx
  • 197
  • 2
  • 14
2
votes
1 answer

Picocli: how to share options between parent command and subcommands

How to support shared options across all (or some) commands and subcommands? For example, if an end user provides --stacktrace anywhere in the command line arguments, any errors printed will include the stacktrace. We can use a Mixin to define a…
Remko Popma
  • 35,130
  • 11
  • 92
  • 114
2
votes
1 answer

Java program options parsing using picocli does not work in Spinnaker Run Job stage

I run my java main program with args using gradle application plugin's run task. The program uses picocli to parse command line args. This works fine when run in my Dev environment using following command: ./gradlew run --args="-ahttp://foo.com/bar…
Farrukh Najmi
  • 5,055
  • 3
  • 35
  • 54
2
votes
2 answers

Picocli: how to show header/banner at all times

Picocli offers the ability to add a nice header in the @Command annotation, for example: @Command(name = "git-star", header = { "@|green _ _ _ |@", "@|green __ _(_) |_ __| |_ __ _ _ _ |@", "@|green / _` | | …
Remko Popma
  • 35,130
  • 11
  • 92
  • 114
2
votes
1 answer

How to reduce slow start for picocli apps due to reflection

Picocli has to introspect the command tree. Doing so it needs to load the domain object classes for every Command which slows down the jvm startup. What options are there to avoid this startup lag? One solution I've come up with is described in…
julius
  • 815
  • 2
  • 7
  • 12
1 2
3
9 10