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

picocli - parse file automatically when specified

I have a CLI with multiple sub-commands, some of the sub-commands have an optional flag -f with which an input file can be specified, e.g. @CommandLine.Command(name = "get", description = ["Get something"]) class GetUserCommand: Runnable { …
wasp256
  • 5,943
  • 12
  • 72
  • 119
0
votes
1 answer

Application runs fine in Intellij but doesn't work when packaged into an exe file

I have built a very simple command line application using picocli and I would like to package it into an executable file. I first packaged it into a jar file using Maven package, and then used Launch4J as recommended by several users on SO to …
Lycanthropeus
  • 195
  • 3
  • 17
0
votes
1 answer

Error message prints after normal exit of the program

I'm writing a CLI app in picocli that will perform an operation a user-specified number of times, it then exits normally after this. However when the program exits picocli prints an 'Unknown Options' error, even though the program has already…
Guilty
  • 464
  • 4
  • 13
0
votes
0 answers

Cannot connect database using picocli and micronaut

I using picocli connect database and build native images. I using micronaut connect to postgres get some data when i excute images native build by picocli. But i have problem when using entityManager. When i using entity manager using @Inject it…
BaoTrung Tran
  • 392
  • 2
  • 6
  • 21
0
votes
1 answer

How to read value from properties using picocli and using it connect postgres

I using picocli and i want build cli get data from database and send it to another service. So i config look like object Student : Table("student") { val id = integer("student_id").autoIncrement().primaryKey() val name = varchar("name",…
BaoTrung Tran
  • 392
  • 2
  • 6
  • 21
0
votes
1 answer

How to start properly a micronaut webserver from picocli command?

I've a micronaut cli application. Some command are long running process that I want to monitor with micronaut endpoints Since when you are on a cli app, micronaut detect and don't launch the webserver. In this long running command, I've added this…
tchiot.ludo
  • 915
  • 1
  • 9
  • 20
0
votes
1 answer

Enabling or Disabling Options during Runtime

I'm trying to make an interactive cli using Picocli, and want to have some options appear after a(n) action/requirement has been completed. Is there a way I can do this without using the CommandSpec? Option to be shown before @Option(names =…
Edmond Chu
  • 11
  • 1
0
votes
1 answer

Picocli Parse Search String

I would like to provide a search string for my program like: cmd.execute("getDevices", "-h 1.2.3.4", "-p myPSW", "-u myUser", "-n red|blue&black,-nonprod"); I want to create predicates to search for hostNames that contain red OR blue AND Black, but…
CoupFlu
  • 311
  • 4
  • 20
0
votes
2 answers

picocli does not work with jline3 in cmd.exe

I want to use picocli with jline3. So I create a project with the following pom.xml:
flaxel
  • 4,173
  • 4
  • 17
  • 30
0
votes
1 answer

Picocli: how to access subcommands after parseWithHandler(new RunAll(), args)?

I have a command with subcommands, which are registered declaratively, and I'm interested in using this style of command line processing: List parsed = commandLine.parseWithHandler(new RunAll(), args); However, for unit testing purposes, I…
Remko Popma
  • 35,130
  • 11
  • 92
  • 114
0
votes
1 answer

Picocli: Is it possible to attach option to parameter when clustered short options are disallowed?

(See also https://github.com/remkop/picocli/issues/488) I have an application that uses a Map field for an option: @Option(names = "-P") Map properties; so users can specify values like: -Pmyprop=myvalue Picocli has an option to…
Remko Popma
  • 35,130
  • 11
  • 92
  • 114
-1
votes
1 answer

PicoCLI ignoring dollar sign in a given string

I am using picocli as a utility to encrypt a given password. In my CLI, I have the option to pass the password String, and a key file. The key file will be used to encrypt the password string. When the password string is containing a dollar ($)…
Panda1667075
  • 147
  • 1
  • 10
-1
votes
2 answers

java -cp Error: Could not find or load main class (java.lang.ClassNotFoundException)

I'm basically following the next tutorial: https://picocli.info/#_running_the_application And I'm trying to run my Application with the next command: java -cp "picocli-4.6.3.jar:bashTool-1.0-SNAPSHOT.jar" src/main/java/TestPicoCli.java --algorithm…
rasilvap
  • 1,771
  • 3
  • 31
  • 70
-1
votes
1 answer

Check the value of an option in a unit test for Picocli

In a unit test for a utility using picocli, I would like to assert that picocli assigned the correct value to the option. How can I get the value associated with an option in a unit test? Here is the current version of the unit test: @Test void…
Oliver
  • 3,815
  • 8
  • 35
  • 63
-1
votes
1 answer

picocli: why does this JUnit test fail?

Test won't run correctly trying to run a JUnit test errors package picocli; import picocli.CommandLine.Option; public class ComparatorRunnerConfig { @Option(names = {"-rc", "--report-class"}, required = false, description =…
Neil Mc Feely
  • 29
  • 1
  • 1
  • 5
1 2 3
9
10