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

How to load external application.yml into the app developed with Micronaut Picocli?

Java: 11.0.7 Micronaut: 2.1.2 Micronaut profile: cli-app I have an application developed with micronaut framework in cli-app profile. My application uses Hibernate and GORM packages, so there are relevant configurations in application.yml In the…
wureka
  • 731
  • 1
  • 11
  • 26
5
votes
1 answer

Why doesn't picocli recognize my option from the command line?

I'm trying to build a CLI in Java using PICOCLI and I'm STUCK at a very basic point. I simply cannot get my application to consumer an option and it's value. Here's my class: package com.example.demo; import…
Saturnian
  • 1,686
  • 6
  • 39
  • 65
5
votes
0 answers

picocli : redirect stdout and stderr to logger

What is the correct/easiest way to redirect output (out/err) from .execute() or .parseArgs() to a logger (org.slf4j.Logger)? (Production processes are often executed by a scheduler with output to application-specific log files. And stdout/err, if…
Kap4Lin
  • 109
  • 5
4
votes
2 answers

Getting Picocli to work with Springboot application

I have to convert a large Spring boot application into a flexible CLI tool, where the requests sent by the Spring boot application (among other things) are determined by user input at the command line. I decided to use picocli to implement the…
Guilty
  • 464
  • 4
  • 13
4
votes
2 answers

How do I specify default subcommand?

Is there a way to print help message when user didn't provide subcommand ? Following doesn't work because it runs callable that doesn't have implementation. @Command( name = "tool", mixinStandardHelpOptions = true, …
expert
  • 29,290
  • 30
  • 110
  • 214
4
votes
1 answer

Testing pico cli commands, Java

I've developed a Java API and I've built a command line interface to consume it using PicoCli What is the proper way to test my pico commands? Thanks in advance
4
votes
2 answers

Howto inject Picocli parsed parameters into Spring Bean definitions?

I'm trying to use Picocli with Spring Boot 2.2 to pass command line parameters to a Spring Bean, but not sure how to structure this. For example, I have the following @Command to specify a connection username and password from the command line,…
Eric B.
  • 23,425
  • 50
  • 169
  • 316
4
votes
1 answer

Implementing interactive confirmation in picocli

In a CLI app built using picocli, what is the most appropriate way to implement an interactive confirmation? The scenario is, when a certain command is run, I need to get a confirmation from the user to do a certain task. I used the interactive…
Imesh Chandrasiri
  • 5,558
  • 15
  • 60
  • 103
3
votes
1 answer

How to use CliBuilder in groovy without options?

I am writing a simple groovy script for which I want a command line as simple as- ./someTask.groovy task-profile Also, the script should have a --help or -h option which specifies all the different values task-profile can take. task-profile can…
3
votes
0 answers

Using picocli with picocli-shell-jline3 and configured java modules leads to unnamed module reads package compile error

On a project with multi modules, we want to use picocli with jline to build a console app. For each module we created a module-info.java. But with picocli we are not able to compile our application. we have tons of errors like module…
3
votes
1 answer

Git Bash in Windows Terminal not rendering Picocli ANSI color codes

I have added Git Bash to Windows Terminal as explained in Adding Git-Bash to the new Windows Terminal. My profile looks as follows: { "guid": "{00000000-0000-0000-ba54-000000000002}", "commandline": "%PROGRAMFILES%/git/usr/bin/bash.exe -i…
HerCerM
  • 145
  • 2
  • 9
3
votes
1 answer

Picocli required options selection based on a primary option

I would like to parse options with picocli in the following format: application -mode CLIENT -c aaaa -d bbbb application -mode SERVER -e xxxx -f yyyy mode is an enum with values { CLIENT, SERVER } If mode == CLIENT, -c and -d options are…
TFuto
  • 1,361
  • 15
  • 33
3
votes
2 answers

Picocli - java.lang.NumberFormatException

@Parameters(index = "0") private Double min_c_re; @Parameters(index = "1") private Double min_c_im; @Parameters(index = "2") private Double max_c_re; @Parameters(index = "3") private Double max_c_im; @Parameters(index = "4") private Integer…
Mixage
  • 115
  • 1
  • 2
  • 6
3
votes
1 answer

picocli exception behavior changed?

I'm in the process of updating from picocli 3.9.6 to 4.2.0, and I'm running into an issue when replacing old deprecated calls with the new versions. In my original version, I had a code block like this: try { return…
marinier
  • 387
  • 3
  • 13
3
votes
1 answer

How to print subcommand result automatically?

I have Java CLI application based on cliche library and I want to migrate it to picocli. My application was based on cliche so I have a lot of methods with asg.cliche.Command annotation which return some result. cliche prints command methods's…
Mariusz
  • 1,907
  • 3
  • 24
  • 39
1
2 3
9 10