cmd/tailscale: make status --peers=false work earlier + in JSON mode

And return an error if you use non-flag arguments.

Change-Id: I0dd6c357eb5cabd0f17020f21ba86406aea21681
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
Brad Fitzpatrick 2022-03-24 13:05:36 -07:00 committed by Brad Fitzpatrick
parent 5df12b9059
commit 06fcf3b225

View File

@ -8,6 +8,7 @@
"bytes"
"context"
"encoding/json"
"errors"
"flag"
"fmt"
"net"
@ -69,7 +70,14 @@
}
func runStatus(ctx context.Context, args []string) error {
st, err := tailscale.Status(ctx)
if len(args) > 0 {
return errors.New("unexpected non-flag arguments to 'tailscale status'")
}
getStatus := tailscale.Status
if !statusArgs.peers {
getStatus = tailscale.StatusWithoutPeers
}
st, err := getStatus(ctx)
if err != nil {
return fixTailscaledConnectError(err)
}