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
0 answers

How to set Spring active profile from Picocli command-line option?

I have a Spring Boot application with Picocli command-line interface. How can I set Spring active profile using Picocli command-line option e.g.: -e=prod?
ajanota
  • 108
  • 5
0
votes
0 answers

Is there a way I can extend a method for its function but not all its CLI options (picocli)

So I'm using picocli and I'm trying to generalize some of my commands in a project. I have 2 classes which share some methods, where one is an extension of the other. They both have options for CLI, but the subclass only needs some of those options,…
0
votes
1 answer

Does Picocli support tar style argument simplification? E.g. 'tar -tvf file' vs 'tar tvf file'

Does picocli support the tar-style option simplification, for example single character options do not required to prefix a group of options with a dash. For example the following are equivalent: tar -t -v -f file tar -tvf file tar tvf file
Jeff McClure
  • 41
  • 1
  • 3
0
votes
1 answer

How to Pass params without specifying their index with Picocli

I'm trying to create a cli program with Picocli that accepts optional options and params. I want the parameters to be always at the end of the passed arguments, however I do not know how to set that. When I try the following, the options are parsed…
0
votes
0 answers

Liquibase version upgrade is not populating artifacts

I am upgrading liquibase from 4.3 to 4.5 and the build artifact updateSql and rollbackSql files are not populating in jenkins. According to this page : https://github.com/liquibase/liquibase-gradle-plugin i even added picocli dependency and changed…
0
votes
2 answers

How do I get picocli to parse `"--item --item foo"` as `[null, "foo"]` `:List`

I have a parameter named --msg-content-list-item public class CliProtonJ2Sender implements Callable { @CommandLine.Option( names = {"--msg-content-list-item"}, arity = "0..1", defaultValue =…
user7610
  • 25,267
  • 15
  • 124
  • 150
0
votes
1 answer

Picocli: argument type mismatch while processing argument at or before arg[1]; converter: String to double[]

This Code: public class Test { @CommandLine.Option(names = {"-c", "--crop"}, converter = Test.checkCropping.class) public double[] foo; public static void main(String[] args) { new CommandLine(new Test()).parseArgs(args); …
0
votes
1 answer

Picocli: How can I decouple @Options attributes from a command class?

I want my app to adhere to the SOLID principles. Using picocli has been a godsend, but annotated @Option attributes are coupled to their respective classes. In my case I want it to be possible to simply put the options into their own classes. So…
0
votes
1 answer

Issue with picocli and GraalVM native-image

I'm trying to build a Java application which will be built into a Linux command line application using native-image provided by GraalVM. I have the below code: @CommandLine.Command( name = "my-application", mixinStandardHelpOptions =…
Ventrue
  • 372
  • 3
  • 17
0
votes
1 answer

Using picoCLI to recursively parse configuration files?

Im answering this question below; I opened it because it is more general than what I originally asked in an earlier question, so it wouldn't really fit there. It took me quite some tinkering, so I thought I'd share the solution here. My situation: I…
LTB
  • 31
  • 3
0
votes
1 answer

Picocli - "Missing required Parameters" even when passed parameters

@Parameters(paramLabel = "AMOUNT", description = "the depth to scrape for") private int amount; @Parameters(paramLabel = "ENTRY_POINT", description = "the entry point for the scrape") private String entryPoint; I have these Parameters in my Main…
0xff
  • 181
  • 2
  • 11
0
votes
1 answer

@Option with enum List does not accept candidates that ${COMPLETION-CANDIDATES} shows

I have an @Option with an enum java.util.List and picocli just does not accept candidates that the ${COMPLETION-CANDIDATES} shows. The way how picocli shows and accepts values does not align with each other. Code: @CommandLine.Option( names =…
zappee
  • 20,148
  • 14
  • 73
  • 129
0
votes
1 answer

How to execute a JAR file from MICRONAUT application, through PICOCLI, with a different environment

I'm trying to run this code from Picocli tutorial: https://micronaut-projects.github.io/micronaut-picocli/latest/guide/#generate Everything works fine, but the application always run with the "CLI" environment. I need to specify which environment I…
Douglas
  • 3
  • 3
0
votes
1 answer

Cli java app that schedule a task, leave free the cmd/terminal and at sheduled time do the task

I'm trying to do a cli aplication in java with spring and picocli that you start it on cmd and with a dialog you do some configurations to program a task, (in this case show an "alarm messege" on the same cmd.) I used Timer and TimerTask and it…
0
votes
0 answers

How can I get all npm install logs and write them in java cli application?

I'm building a command Line application with java picocli that basically wraps npm, maven, git, azure, and some utility commands I want to have pre-done. My issue is when for example npm install is run, it prints a whole array of stuff like warning…