Skip to content

Nested subcommands #13

Description

@vertexmachina

Is it possible to have subcommands within subcommands?

I'd like the ability to do something like remote channel change 5, or remote channel read, where channel is the main subcommand and change and read are subcommands that are part of the channel subcommand.

I've attempted to do it with a yuck file like this:

Usage: remote
Interact with a television.

Usage: remote power on
Power on the television

Usage: remote power off
Power off the television

Usage: remote channel change [CHANNEL]...
Change channel to CHANNEL

Usage: remote channel read
Read current channel

Which generates the following:

$ ./remote --help

Usage: remote [OPTION]... COMMAND

Interact with a television.

COMMAND may be one of:
  power       Power off the television
  channel     Read current channel

Options accepted by all commands:
  -h, --help            display this help and exit
  -V, --version         output version information and exit
$ ./remote power --help

Usage: remote power off

Power off the television

Common options:
  -h, --help            display this help and exit
  -V, --version         output version information and exit
$ ./remote channel --help
Usage: remote channel read

Read current channel

Common options:
  -h, --help            display this help and exit
  -V, --version         output version information and exit

As you can see, it seems to only register the last sub-subcommand (e.g., power off and channel read) in the yuck file.

Is this functionality already present and I'm doing it incorrectly? If it isn't present, would the current architecture allow for it to be easily added? I would be happy to contribute.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions