cmd/tailscale/cli: ensure custom UsageFunc is always set (#8665)

Updates #6995

Signed-off-by: Chris Palmer <cpalmer@tailscale.com>
bradfitz/negdep
Chris Palmer 1 year ago committed by GitHub
parent 3c53bedbbf
commit 32d486e2bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -134,11 +134,6 @@ change in the future.
Exec: func(context.Context, []string) error { return flag.ErrHelp },
UsageFunc: usageFunc,
}
for _, c := range rootCmd.Subcommands {
if c.UsageFunc == nil {
c.UsageFunc = usageFunc
}
}
if envknob.UseWIPCode() {
rootCmd.Subcommands = append(rootCmd.Subcommands,
idTokenCmd,
@ -156,6 +151,12 @@ change in the future.
rootCmd.Subcommands = append(rootCmd.Subcommands, configureHostCmd)
}
for _, c := range rootCmd.Subcommands {
if c.UsageFunc == nil {
c.UsageFunc = usageFunc
}
}
if err := rootCmd.Parse(args); err != nil {
if errors.Is(err, flag.ErrHelp) {
return nil

Loading…
Cancel
Save