Search code examples
javacommand-lineannotationspicocli

Splitting a command in PicoCLI


I'm using picocli to implement a cli tool and I've got a command which looks like the following.

mainCommand subCommand <parameter1>:<parameter2> parameter3

The question I have is how to map the parameter and parameter2 as picoCli parameters using the picoCli annotation. The following is my approach on the annotations.

@CommandLine.Parameters(index = "0", split = ":")
private List<String> moduleParam;

Is the above the correct way to annotate the parameters or is there a better way on implementing the annotation. Please advice.


Solution

  • The split attribute can be used for both named options and positional parameters.

    What you’re doing looks fine to me.