You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey, I am trying to call a command with a specific flag from another command but I've been struggling to make it work. Here is what I am doing:
varstartCmd=&cobra.Command{
Use: "start",
Short: "The central command for the CLI.",
Long: `start can execute any of the other commands in the CLI.`,
Run: func(cmd*cobra.Command, args []string) {
getCmd.SetArgs([]string{"--data", "price"})
getCmd.Run(cmd, os.Args[1:])
// getCmdRun(cmd, []string{"--data", "price"}) -> tried this as well but failed too
},
}
funcinit() {
rootCmd.AddCommand(startCmd)
startCmd.AddCommand(getCmd)
}
Each time it raises a warning from the getCmd command saying my flag is not recognized. How do we do that?
The text was updated successfully, but these errors were encountered:
Hey, I am trying to call a command with a specific flag from another command but I've been struggling to make it work. Here is what I am doing:
Each time it raises a warning from the
getCmd
command saying my flag is not recognized. How do we do that?The text was updated successfully, but these errors were encountered: