-
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
Execute several commands at once. #482
Comments
What's the problem to just call the package main
import (
"github.com/spf13/cobra"
)
var c1 = &cobra.Command{Use: "c1", Run: runC1}
var c2 = &cobra.Command{Use: "c2", Run: runC2}
func runC1(cmd *cobra.Command, args []string) {
// do something
}
func runC2(cmd *cobra.Command, args []string) {
// do something
c1.Execute(cmd, args)
// do somethind
}
func init() {
c1.AddCommand(c2)
}
func main() {} |
Thanks. This is exactly what i need. Maybe you can add it in examples of Readme.
|
No, I think it's obvious solution
But Run and Execute are different things actually. It depends on what you need. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For example i have command called "Init". What i should to write in this command, if i want when i start this command "Init" it will trigger to execute some number of subcommands?
The text was updated successfully, but these errors were encountered: