-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
How can I call other subcommands? #1168
Comments
@pencil001 you might find the discussion in #726 interesting.
You need to call the parent Execute by providing the subset of args that you want, instead of calling the Execute function of each child. |
This issue is being marked as stale due to a long period of inactivity |
@umarcor I did the exact thing that you described and still I am getting stack overflow.
Here I am expecting this multi command to work like my-cli deploy multi alpha,beta,gamma |
@saltperfect please open a new issue and provide a complete reproducible example of what you are trying to achieve and how you are trying to do it. |
With the new issue having been opened I'm going to close this one. |
Also talked about here: #379 |
I have built an cli application like this:
Now, I want to add another subcommand
all
, like thisThis command will execute all the logic of sth1, sth2, ...., sthn.
Naturally, I don't want to duplicate codes, so I have two options:
cmd.Run
This option has some cons. If other command has defined
PreRun
orPostRun
, it will ignore those code. And those flags defined on those command will be ignored, too.Execute
This option is just not work. Because
Execute
will find every command's root command to execute. And all subcommands have same parent command, it will cause stackoverflow.Can anybody give me some advices? Thank you!
The text was updated successfully, but these errors were encountered: