cmd/tailscale/cli: add option to delete a profile

pull/12325/head
qingyunha 5 months ago
parent 42cfbf427c
commit df710c00a9

@ -31,6 +31,7 @@ This command is currently in alpha and may change in the future.`,
FlagSet: func() *flag.FlagSet { FlagSet: func() *flag.FlagSet {
fs := flag.NewFlagSet("switch", flag.ExitOnError) fs := flag.NewFlagSet("switch", flag.ExitOnError)
fs.BoolVar(&switchArgs.list, "list", false, "list available accounts") fs.BoolVar(&switchArgs.list, "list", false, "list available accounts")
fs.BoolVar(&switchArgs.delete, "delete", false, "delete a account")
return fs return fs
}(), }(),
Exec: switchProfile, Exec: switchProfile,
@ -66,6 +67,7 @@ func init() {
var switchArgs struct { var switchArgs struct {
list bool list bool
delete bool
} }
func listProfiles(ctx context.Context) error { func listProfiles(ctx context.Context) error {
@ -139,6 +141,13 @@ func switchProfile(ctx context.Context, args []string) error {
printf("Already on account %q\n", args[0]) printf("Already on account %q\n", args[0])
os.Exit(0) os.Exit(0)
} }
if switchArgs.delete {
if err := localClient.DeleteProfile(ctx, profID); err != nil {
errf("Failed to delete account: %v\n", err)
os.Exit(1)
}
os.Exit(0)
}
if err := localClient.SwitchProfile(ctx, profID); err != nil { if err := localClient.SwitchProfile(ctx, profID); err != nil {
errf("Failed to switch to account: %v\n", err) errf("Failed to switch to account: %v\n", err)
os.Exit(1) os.Exit(1)

Loading…
Cancel
Save