question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Is is possible to create nested/subcommands?

See original GitHub issue

I am trying to achieve nested/subcommands but it’s a bit challenging. Is it possible at the moment, or it would need to be implemented?

e.g. my-cli pizza create order --verbose

commander is supporting it through the following approach: https://github.com/tj/commander.js/blob/master/examples/nestedCommands.js

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
cdbkrcommented, Sep 20, 2021

thanks for the clarification! Probably following the Module approach embraced by NestJS wouldn’t play well with Commander’s subcommand features, because it’s like you stated in the last comment: even parent’s command can have its own implementation. The Example you pasted looks good to me. Instead, what do you think about the opposite, leaving the parents to register the first level subcommands?

@Command('up')
export class UpCommand implements CommandRunner {}

@Command('compose', {  subcommands: [ UpCommand ]})
export class ComposeCommand implements CommandRunner {}
0reactions
jmcdo29commented, Oct 2, 2021

closed by #67. Available in 2.3.0

Read more comments on GitHub >

github_iconTop Results From Across the Web

Nested SubCommands - Typer
Typer, build great CLIs. Easy to code. Based on Python type hints.
Read more >
Creating nested subcommands using Thor - Stack Overflow
I have successfully used subcommands of subcommands, although there is a small bug. I haven't tried preserving class_options for subcommands ...
Read more >
Sub-subcommands (nested commands) · Issue #127 - GitHub
Yes, there should be no need to implement any interfaces or do anything other than the normal annotations for nested subcommands. Ease of...
Read more >
Executing Nested Commands - Clikt
Clikt supports arbitrarily nested commands. You can add one command as a child of another with the subcommands function, which can be called...
Read more >
CLI with nested sub-commands and tab completion : r/rust
Yes, clap integrated structopt and supports nested subcommands. Structopt only works with clap v2 libraries and clap_complete only works with ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found