I know this question has been asked many times here and elsewhere when I am looking for an answer. However, it still puzzles me why the command line analyzer library does not provide this common use case, where I have a group of subcommands, each subcommand has its own set of mandatory and optional arguments. A similar constructor can be found in git / svn, although in this case the subcommand command is a standalone program if I am not mistaken.
To summarize, I am looking for an easy way:
top_command subcmd_A [ command A options ....] top_command subcmd_B [ command B options ....] ...
In the java world, two commonly mentioned libraries are Apache Command CLI and JSAP. I donβt see any of them having this in mind - although you could probably tweak and configure a lot to fit ... but the main flow of defining the option, register ... then, at the end, analyze them all , t, in order to consider the case with different subcommands, validation and parser must behave differently.
Maybe the general wisdom here is that it is too specific for the application and should be left to the application itself. One way I can think of is to define a BaseCommand class, and each subcommand extends it and registers itself ... as a way to break it down for ease of management. If any mature framework can do this, I would appreciate any pointer here.
I could be mistaken in my understanding of the current ability of the parser, although any understanding is much appreciated.
Oliver
Oliver
source share