diff --git a/cli/main.go b/cli/main.go index 90baeab25..e3ce87cfa 100644 --- a/cli/main.go +++ b/cli/main.go @@ -101,12 +101,16 @@ func isContextAgnosticCommand(cmd *cobra.Command) bool { if cmd == nil { return false } - if _, ok := contextAgnosticCommands[cmd.Name()]; ok { + if _, ok := contextAgnosticCommands[cmd.Name()]; ok && isFirstLevelCommand(cmd) { return true } return isContextAgnosticCommand(cmd.Parent()) } +func isFirstLevelCommand(cmd *cobra.Command) bool { + return !cmd.HasParent() || !cmd.Parent().HasParent() +} + func main() { var opts cliopts.GlobalOpts root := &cobra.Command{