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
You cannot do this. Each command can only have one parent. For your use case you would need to generate the command with a function and invoke it for each addcommand call. Like #1015 (comment)
app get schedule
** AND **
app create schedule
for the following code:
var scheduleCmd = &cobra.Command{
Use: "schedule",
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("schedule parent is ", cmd.Parent().Use)
},
}
func init() {
createCmd.AddCommand(scheduleCmd)
getCmd.AddCommand(scheduleCmd)
}
The reverse is also true if I reverse the order AddCommand. cmd.Parent() returns the LAST parent added, regardless of the actual command's parent.
The text was updated successfully, but these errors were encountered: