I have a command with subcommands. In my application I want it mandatory for the user to specify a subcommand. How should I do this?
(See also https://github.com/remkop/picocli/issues/529)
I have a command with subcommands. In my application I want it mandatory for the user to specify a subcommand. How should I do this?
(See also https://github.com/remkop/picocli/issues/529)
Update: this is now documented in the picocli manual: https://picocli.info/#_required_subcommands
Prior to picocli 4.3, the way to achieve this would be to show an error or throw a
ParameterExceptionif the top-level command is invoked without subcommand.For example:
From picocli 4.3, this can be accomplished more easily by making the top-level command not implement
RunnableorCallable.If the command has subcommands but does not implement
RunnableorCallable, picocli will make subcommands mandatory.For example: