Skip to content

Run cli and execute a default subcommand #2141

Answered by remkop
shaikhu asked this question in Q&A
Discussion options

You must be logged in to vote

One way to accomplish this is to let the top-level cli command delegate to the basic subcommand:

  • make the top-level cli command implement Callable<Integer> just like the basic subcommand;
  • copy all options and positional parameters from the basic subcommand to the top-level cli command
  • optionally make these options and positional parameters hidden in the top-level cli command, so they don't show up in the usage help for the top-level command
  • in the call method of the top-level command, delegate to the basic command (copy all options/params to an instance of basic, and call its call method)

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@shaikhu
Comment options

Answer selected by shaikhu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants