picocli

"Missing Required Options" warning message not displayed for missing options


I am implementing picocli in my groovy script that takes couple of Required Options and couple of Optional Options.

When I run my script without passing any commandline argument ( i.e. just groovy my-script.groovy ) , it displays warning message "Missing Required Options" for the Options marked with "required = true" which is expected and hence fine.

But when I pass in just the Optional Option without providing any parameter (i.e. just --middle-name) and also without any of the Required Options then I get the warning message "Missing required parameter for option" but no warning for the missing "Required Options" is diplayed.

E.g.:

Lets say,

Required options (required=true) : --first-name and --last-name

Optional option(required=false) : --middle-name

Scenario 1:

groovy my-script.groovy

Missing required options: '--first-name=firstName', '--last-name=lastName'

Scenario 2:

groovy my-script.groovy --middle-name

Missing required parameter for option '--middle-name' (middleName)

In the case of Scenario 2 I would also expect the Missing required options: '--first-name=firstName', '--last-name=lastName'

What could be the causing this.


Solution

  • The picocli parser does not try to find all errors, it simply stops as soon as a problem is found.

    Since the optional option --middle-name was specified, but without an option parameter, the picocli parser shows an error message that this option requires a value.

    If you were to specify a value for the --middle-name option, like this:

    groovy my-script.groovy --middle-name=john
    

    picocli would then show an error message for the next problem it encounters: Missing required options: '--first-name=firstName', '--last-name=lastName'