cmd/tailscale/cli: add hidden debug subcommand

This commit is contained in:
Brad Fitzpatrick
2020-08-24 21:23:37 -07:00
parent 169ff22a84
commit 1be6c6dd70
2 changed files with 82 additions and 0 deletions

View File

@@ -32,6 +32,7 @@ func ActLikeCLI() bool {
}
switch os.Args[1] {
case "up", "status", "netcheck", "ping", "version",
"debug",
"-V", "--version", "-h", "--help":
return true
}
@@ -66,6 +67,11 @@ change in the future.
Exec: func(context.Context, []string) error { return flag.ErrHelp },
}
// Don't advertise the debug command, but it exists.
if strSliceContains(args, "debug") {
rootCmd.Subcommands = append(rootCmd.Subcommands, debugCmd)
}
if err := rootCmd.Parse(args); err != nil {
return err
}
@@ -127,3 +133,12 @@ func pump(ctx context.Context, bc *ipn.BackendClient, conn net.Conn) {
bc.GotNotifyMsg(msg)
}
}
func strSliceContains(ss []string, s string) bool {
for _, v := range ss {
if v == s {
return true
}
}
return false
}