Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there a way to support two layers of sub-commands? #25

Closed
geneliu opened this issue May 12, 2021 · 1 comment
Closed

Is there a way to support two layers of sub-commands? #25

geneliu opened this issue May 12, 2021 · 1 comment

Comments

@geneliu
Copy link

geneliu commented May 12, 2021

Just wonder if there is possibility or how much of the work to support sub-sub-commands?

e.g.:
command sub-command1 sub-sub-command1

@ko1nksm
Copy link
Owner

ko1nksm commented May 12, 2021

Hi,

I have not tried this, but it should already be supported.

e.g.:
command sub-command1 sub-sub-command1

Supplemented it with options/arguments to make it look like follows:

command [global-options] sub-cmd1 [options-for-sub-cmd1] sub-sub-cmd1 [options-for-sub-sub-cmd1] [arguments] 

To parse it, we need to perform three parses.

First parse (for command):

command [global-options] <sub-cmd> {doesn't care about the rest}

Second parse (for sub-cmd1):

sub-cmd1 [options-for-sub-cmd1] <sub-sub-cmd> {doesn't care about the rest}

Third parse (for sub-sub-cmd1):

sub-sub-cmd1 [options-for-sub-sub-cmd1] [arguments]

In other words, the number of subcommands+1 parser definition is required. Defining this in a single shell script would make it hard to read, but if we were developing something large enough to require this, we will separate each subcommand into its own file. In other words, the parser definition is defined in the main shell script and in the shell script for each subcommand.

See also #16.

@ko1nksm ko1nksm closed this as completed May 12, 2021
Repository owner locked and limited conversation to collaborators May 12, 2021

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants