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
1
vote
1 answer

Appropriate way to implement a cli Application which also uses the service profile with Micronaut

I've no problem in creating a REST Server or a Picocli CLI Application. But what if I want to have both in one Application? The thing is, I want to have an Application which provides some business logic via REST Server (no problem there), but in…
sren
  • 13
  • 4
1
vote
1 answer

make picocli parse local date format

PicoCLI accepts 2019-04-26 as input for a LocalDate variable, but it does not accept the German Date format like 26.04.2019. For that you need: SimpleDateFormat format = new SimpleDateFormat("dd.MM.yyyy",Locale.GERMANY); How do you tell to PicoCLI…
James Baker
  • 107
  • 2
  • 11
1
vote
1 answer

Picocli option list alignment problem in usage-help message

I am using a command using PicoCLI v4.0.0-alpha-3. No matter which options I try, the one that shows at the top (when the list of options is displayed in the CL) is always to the right of the other options. How can this be configured so that all…
ali haider
  • 19,175
  • 17
  • 80
  • 149
1
vote
2 answers

Picocli command hierarchy in JLine

I am using Pico CLI v4.0.0-alpha-3 & jline v3. I have the following class (using annotations). When I run the main class, I cannot seem to run the command and get the callable invoked. I can invoke the callable if I simply pass in the parameters.…
ali haider
  • 19,175
  • 17
  • 80
  • 149
1
vote
1 answer

Picocli: can the parser be configured using annotations?

I use PicoCLI to parse the arguments. I need to specify setStopAtPositional(true) for one of the subcommands. Is there a way to do this with an annotation? Currently I do this: cmd.getSubcommands().get("submit").setStopAtPositional(true); But it…
Oliv
  • 10,221
  • 3
  • 55
  • 76
1
vote
1 answer

Non-zero exit code on missing parameter with picocli

I have a simple Command with one mandatory parameter: @Parameters(index = "0", description = "manifest") private File manifest; When I call it from the command line without a parameter I get the expected message: Missing required parameter:…
Chirlo
  • 5,989
  • 1
  • 29
  • 45
1
vote
2 answers

How to convert picocli groovy-grape script to native standalone app?

I have a made my first groovy CLI app with picocli. Now, I want it to be available for use without any JVM installed on the client machine, maybe with the use of GraalVM. This is for an opensource project: https://github.com/kchaitanya863/db2csv
1
vote
1 answer

Picocli: Separate reponsibilities of class property population and application execution

Before using a cli I would have a starter class which calls my ApplicationPropertiesProvider class (which reads my properties file) and then kicks off the business logic. So there was a separation, the ApplicationPropertiesProvider just had one…
J. Doe
  • 142
  • 1
  • 14
1
vote
1 answer

Scalable applications with picocli. Best practice question

Say my project does a lot of logic, and has a few entry points, them being CLI commands. I annotate my entry points with @Command, initialize my @Parameters and @Option annotated fields and perform logic, that doesn't require the CLI anymore. As I…
saæ
  • 183
  • 1
  • 14
1
vote
1 answer

Groovy-Eclipse 2.5.2: java.lang.ClassNotFoundException: picocli.CommandLine$ParameterException

I'm using Eclipse 4.5 with the Groovy-Eclipse 2.9.2/4.5 plugin which I thought was supposed to have the Groovy 2.5 compiler. However, it didn't have any picocli support so I added the groovy-cli-picocli-2.5.2-indy.jar to my classpath and was able…
AndyJ
  • 1,204
  • 3
  • 14
  • 28
1
vote
2 answers

Picocli: Best way to specify option with optional value that prints current value when no value specified

I'm writing a REPL (so I'm using picocli internally to parse commands typed within the application, not to parse command line args), and I have a command with an option that I want to behave like this: > cmd --myopt Myopt value = 5 > cmd --myopt 4 >…
Remko Popma
  • 35,130
  • 11
  • 92
  • 114
1
vote
1 answer

Picocli, how to recognise presence of option with optional value and custom type converter

Picocli v2.3.0. @CommandLine.Option(names = {"--number-headings"}, arity = "0..1", paramLabel = "levels", description = {"Adds numbers to headings. Optional parameter to set the heading…
Jesse
  • 3,751
  • 1
  • 21
  • 19
0
votes
1 answer

Picocli with long running Javalin Thread

I want to build a simple Javalin API and configure the HTTP port with a command line arg with Picocli. It looks a bit like this: public class Main implements Runnable { @CommandLine.Option(names = {"-p", "--port"}) int httpPort = 9080; …
Thomas
  • 793
  • 1
  • 8
  • 16
0
votes
0 answers

Error: Path entry 'axis.jar' does not map to a real path. Error: Image build request failed with exit status 1

I am attempting to build a native image for my picocli application using GraalVM, and I am encountering an error: Error: Path entry 'axis.jar' does not map to a real path. Error: Image build request failed with exit status 1 I used the following…
0
votes
0 answers

How can I create a multiple choice prompt in picocli?

I'm trying to create a cli with a option prompt, like the image below.
Kaigo
  • 1,267
  • 2
  • 14
  • 33