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
{{ message }}
Repository navigation
--hints, --stats and --verbose are ignored on subcommands in release builds #954
Seen with a make build binary (version 0.17.1-…, not dev) and no hints key in config. A dev build hides the bug, because version.IsDev() turns hints on by default.
Cause.resolvePreferences is called from the root's PersistentPreRunE with cmd set to the subcommand being run. It asks cmd.PersistentFlags().Changed("hints"). A subcommand's own persistent flag set does not contain the root's --hints, so Changed is false and the config or IsDev() default overwrites the explicit flag:
--stats and --verbose share the check. For --stats, the config value or the IsDev() default overrides the explicit flag. For --verbose, a config value does. --no-hints still works, because App.OK reads flags.NoHints directly. root_test.go calls resolvePreferences with the root command, where PersistentFlags() does hold the flags, so it passes.
Fix. Use cmd.Flags().Changed(...), which includes inherited persistent flags once parsed. Add a test that runs a subcommand with --hints against a non-dev version.
Activity