Skip to content

Commit

Permalink
cmd/tailscale/cli: ensure custom UsageFunc is always set (tailscale#8665
Browse files Browse the repository at this point in the history
)

Updates tailscale#6995

Signed-off-by: Chris Palmer <cpalmer@tailscale.com>
Signed-off-by: Alex Paguis <alex@windscribe.com>
  • Loading branch information
Chris Palmer authored and alexelisenko committed Feb 15, 2024
1 parent 8a59cc4 commit 4c564f9
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions cmd/tailscale/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down

0 comments on commit 4c564f9

Please sign in to comment.