cmd/tailscale/cli: prepend "tailscale" to usage errors

Updates #11626

Signed-off-by: Paul Scott <paul@tailscale.com>
pull/11772/head
Paul Scott 4 weeks ago committed by Paul Scott
parent d07ede461a
commit 454a03a766

@ -842,7 +842,7 @@ var debugComponentLogsArgs struct {
func runDebugComponentLogs(ctx context.Context, args []string) error { func runDebugComponentLogs(ctx context.Context, args []string) error {
if len(args) != 1 { if len(args) != 1 {
return errors.New("usage: debug component-logs [" + strings.Join(ipn.DebuggableComponents, "|") + "]") return errors.New("usage: tailscale debug component-logs [" + strings.Join(ipn.DebuggableComponents, "|") + "]")
} }
component := args[0] component := args[0]
dur := debugComponentLogsArgs.forDur dur := debugComponentLogsArgs.forDur
@ -865,7 +865,7 @@ var devStoreSetArgs struct {
func runDevStoreSet(ctx context.Context, args []string) error { func runDevStoreSet(ctx context.Context, args []string) error {
if len(args) != 2 { if len(args) != 2 {
return errors.New("usage: dev-store-set --danger <key> <value>") return errors.New("usage: tailscale debug dev-store-set --danger <key> <value>")
} }
if !devStoreSetArgs.danger { if !devStoreSetArgs.danger {
return errors.New("this command is dangerous; use --danger to proceed") return errors.New("this command is dangerous; use --danger to proceed")
@ -883,7 +883,7 @@ func runDevStoreSet(ctx context.Context, args []string) error {
func runDebugDERP(ctx context.Context, args []string) error { func runDebugDERP(ctx context.Context, args []string) error {
if len(args) != 1 { if len(args) != 1 {
return errors.New("usage: debug derp <region>") return errors.New("usage: tailscale debug derp <region>")
} }
st, err := localClient.DebugDERPRegion(ctx, args[0]) st, err := localClient.DebugDERPRegion(ctx, args[0])
if err != nil { if err != nil {

@ -554,7 +554,7 @@ func runFileGetOneBatch(ctx context.Context, dir string) []error {
func runFileGet(ctx context.Context, args []string) error { func runFileGet(ctx context.Context, args []string) error {
if len(args) != 1 { if len(args) != 1 {
return errors.New("usage: file get <target-directory>") return errors.New("usage: tailscale file get <target-directory>")
} }
log.SetFlags(0) log.SetFlags(0)

@ -19,7 +19,7 @@ var idTokenCmd = &ffcli.Command{
func runIDToken(ctx context.Context, args []string) error { func runIDToken(ctx context.Context, args []string) error {
if len(args) != 1 { if len(args) != 1 {
return errors.New("usage: id-token <aud>") return errors.New("usage: tailscale id-token <aud>")
} }
tr, err := localClient.IDToken(ctx, args[0]) tr, err := localClient.IDToken(ctx, args[0])

@ -33,7 +33,7 @@ func runNC(ctx context.Context, args []string) error {
} }
if len(args) != 2 { if len(args) != 2 {
return errors.New("usage: nc <hostname-or-IP> <port>") return errors.New("usage: tailscale nc <hostname-or-IP> <port>")
} }
hostOrIP, portStr := args[0], args[1] hostOrIP, portStr := args[0], args[1]

@ -461,7 +461,7 @@ func runNetworkLockSign(ctx context.Context, args []string) error {
) )
if len(args) == 0 || len(args) > 2 { if len(args) == 0 || len(args) > 2 {
return errors.New("usage: lock sign <node-key> [<rotation-key>]") return errors.New("usage: tailscale lock sign <node-key> [<rotation-key>]")
} }
if err := nodeKey.UnmarshalText([]byte(args[0])); err != nil { if err := nodeKey.UnmarshalText([]byte(args[0])); err != nil {
return fmt.Errorf("decoding node-key: %w", err) return fmt.Errorf("decoding node-key: %w", err)
@ -508,7 +508,7 @@ func runNetworkLockDisable(ctx context.Context, args []string) error {
return err return err
} }
if len(secrets) != 1 { if len(secrets) != 1 {
return errors.New("usage: lock disable <disablement-secret>") return errors.New("usage: tailscale lock disable <disablement-secret>")
} }
return localClient.NetworkLockDisable(ctx, secrets[0]) return localClient.NetworkLockDisable(ctx, secrets[0])
} }
@ -545,7 +545,7 @@ var nlDisablementKDFCmd = &ffcli.Command{
func runNetworkLockDisablementKDF(ctx context.Context, args []string) error { func runNetworkLockDisablementKDF(ctx context.Context, args []string) error {
if len(args) != 1 { if len(args) != 1 {
return errors.New("usage: lock disablement-kdf <hex-encoded-disablement-secret>") return errors.New("usage: tailscale lock disablement-kdf <hex-encoded-disablement-secret>")
} }
secret, err := hex.DecodeString(args[0]) secret, err := hex.DecodeString(args[0])
if err != nil { if err != nil {

@ -95,7 +95,7 @@ func runPing(ctx context.Context, args []string) error {
} }
if len(args) != 1 || args[0] == "" { if len(args) != 1 || args[0] == "" {
return errors.New("usage: ping <hostname-or-IP>") return errors.New("usage: tailscale ping <hostname-or-IP>")
} }
var ip string var ip string

@ -52,7 +52,7 @@ func runSSH(ctx context.Context, args []string) error {
return errors.New("The 'tailscale ssh' subcommand is not available on macOS builds distributed through the App Store or TestFlight.\nInstall the Standalone variant of Tailscale (download it from https://pkgs.tailscale.com), or use the regular 'ssh' client instead.") return errors.New("The 'tailscale ssh' subcommand is not available on macOS builds distributed through the App Store or TestFlight.\nInstall the Standalone variant of Tailscale (download it from https://pkgs.tailscale.com), or use the regular 'ssh' client instead.")
} }
if len(args) == 0 { if len(args) == 0 {
return errors.New("usage: ssh [user@]<host>") return errors.New("usage: tailscale ssh [user@]<host>")
} }
arg, argRest := args[0], args[1:] arg, argRest := args[0], args[1:]
username, host, ok := strings.Cut(arg, "@") username, host, ok := strings.Cut(arg, "@")

Loading…
Cancel
Save