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
3
votes
1 answer

Customized help display in PicoCli?

I have a use case where I need to post the entire help for a CLI in a specified format. I have found a way to do that using the following: @CommandLine.Command(name="myAp", synopsisSubcommandLabel = "", usageHelpWidth = 120, …
Mark
  • 2,058
  • 2
  • 35
  • 64
3
votes
1 answer

Picocli: Specify default value for an option which has a type of Map

I have an option like so @CommandLine.Option(names = "-D", description = "Define a symbol.") /* A list of defines provided by the user. */ Map defines = new LinkedHashMap(); This does work when I do the…
Har
  • 3,727
  • 10
  • 41
  • 75
3
votes
1 answer

completion Candidates for positional parameter in picocli

I'm trying to provide completion for positional parameters. Somewhere I found note that they are not very well supported, but currently I'm not able to find exact place in spec and I'm not sure what that really means. In meantime I found…
zimi
  • 1,586
  • 12
  • 27
3
votes
1 answer

Picocli: How can one handle no arguments and options scenario

I am using the picocli java command line library to implement a command line application. However I would like to know whether picocli offers a feature that can help handle the situation where the command line does not receive any arguments or…
Arsene
  • 1,037
  • 4
  • 20
  • 47
3
votes
1 answer

How can I handle errors in picocli?

I try to implement my own CLI and want to use picocli for parsing my commands' arguments. That's why I don't want picocli to write in console at all. So I created class MyCommand with some option and parameters annotations. Now I want to be able to…
Okumo
  • 169
  • 1
  • 12
3
votes
1 answer

Picocli: how to make subcommands required

I have a command with subcommands. In my application I want it mandatory for the user to specify a subcommand. How should I do this? (See also https://github.com/remkop/picocli/issues/529)
Remko Popma
  • 35,130
  • 11
  • 92
  • 114
3
votes
2 answers

CLI with Picocli: Call main command before sub command get called

I switched from Apache Commons CLI to Picocli because of the sub command support (and annotation-based declaration). Consider a command line tool like git, with sub commands like push. Git have a main switch --verbose or -v for enable verbose mode…
Vertex
  • 2,682
  • 3
  • 29
  • 43
2
votes
0 answers

How can I add Interface's fields as option in picocli?

I have a problem while refactoring my code that uses picocli Here's the example @Command(name='-classA') class A{ @Options(names = '-n1') public int num1; @Options(names = '-n2') public int num2; public void testA(){ …
Leo Ha
  • 21
  • 2
2
votes
2 answers

picocli: show help if no parameter given

I would like to show the help automatically when I run my CLI app without parameters. I have seen that this question appears multiply times on StackOverflow. I spent significant time figuring this out, I have read the official document, checked…
zappee
  • 20,148
  • 14
  • 73
  • 129
2
votes
1 answer

Picocli Spring boot CLI Application

I am trying to create a spring boot CLI App using picocli. I followed the steps as mentioned in the tutorial, but when I start the service the whole flow runs. What I want is to call the command from the terminal then only the flow should…
SS12345
  • 21
  • 3
2
votes
1 answer

How do I make a picoCLI project into a command?

I have a working project with command line variables. It works when I run it In IntelliJ with the command line options, how do I make it into a full terminal command?
2
votes
1 answer

Graal native-image command returns error "Please specify class containing the main entry point method"

My application that is built with gradle is not able to be packaged with graal's native image command. I build the combined jar using: gradlew --no-daemon assemble Then, I test my cli application using: java -jar…
Eddie Greathouse
  • 125
  • 1
  • 5
  • 14
2
votes
1 answer

PicoCLI : How can I use @ArgGroup for a method?

I want to have mutually exclusive command options for the below snippet : @Command(description = "test command") public void test( @Option(names = { "-a"}, required = true, arity = "0", description = "print A") boolean a, …
Ankit
  • 99
  • 6
2
votes
1 answer

How to use picocli to handle option with multiple types

I'm converting an existing application to use picocli. One of the existing options looks like this: -t, --threads [1, n] for fixed thread pool, 'cpus' for number of cpus, 'cached' for cached This allows the option to be a positive integer…
marinier
  • 387
  • 3
  • 13
2
votes
1 answer

Text formating is not applied in CLI - using PICOCLI java

I've been trying to display formatted texts on CLI. I tried the exact same code provided in picocli docs (doc link), but the formatting does not seem to be applied. Please help me to identify my mistake. Expected output My code import…
curiousredoC
  • 51
  • 1
  • 7
1
2
3
9 10