Determine if flags were actually passed in (sub)command invocation in golang's cobra/viper
I have a cobra command var mycommandCmd = &cobra.Command{ Use: "mycommand", PersistentPreRunE: func(cmd *cobra.Command, args []string) error { viper.BindPFlags(cmd.Flags()) and a subcommand var mysubcommandCmd = &cobra.Command{ Use: "mysubcommand", Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { viper.BindPFlags(cmd.Flags()) which I of course bind together mycommandCmd.AddCommand(mysubcommandCmd) I also have some flags for both of them mycommandCmd.PersistentFlags().BoolP("foo",… Read More Determine if flags were actually passed in (sub)command invocation in golang's cobra/viper