jcommander icon indicating copy to clipboard operation
jcommander copied to clipboard

Better Error Message When Using Multiple Commands

Open roblaks opened this issue 8 years ago • 1 comments

I have a CLI parser that is using JCommander. Overall I'm pretty happy with the results, but I've got an issue where the error message that is specified is when two command names are provided in the CLI is a little misleading. See example below:

./SampleApp -v command2 -o someOutputDir command1

ERROR: Was passed main parameter 'command1' but no main parameter was defined
Usage: SampleApp [options] [command] [command options]
 Options:
   -h, --help
     Prints out usage documentation.
     Default: false
   -v, --verbose
     Prints execution steps and verification info.
     Default: false
 Commands:
   command1      Description for command1.
     Usage: command1 [options]
       Options:
         -et, --endTime
           End time in UTC.

    command2      Description for command2
     Usage: command2 [options]
       Options:
       * -o, --outputDirectory
           Directory to place output files.

In my case neither command has a main parameter, so when the second command is supplied it looks like JCommander attempts to treat it as a main parameter but cannot find a main parameter to apply it to. I'd prefer to see a little extra work and have JCommander attempt to find a command name/alias that this argument matches and if found displays an error message stating that only one command may be supplied.

roblaks avatar Apr 05 '17 20:04 roblaks

+1

fpoolev avatar Jun 16 '17 00:06 fpoolev