mirror of
https://github.com/tailscale/tailscale.git
synced 2024-11-25 19:15:34 +00:00
cmd/tailscale/cli: make 'debug watch-ipn' play nice with jq
jq doens't like non-json output in the json stream, and works more happily when the input stream EOFs at some point. Move non-json words to stderr, and add a parameter to stop watching and exit after some number of objects. Updates #cleanup Signed-off-by: David Anderson <danderson@tailscale.com>
This commit is contained in:
parent
c4855fe0ea
commit
fd22145b52
@ -189,6 +189,7 @@
|
||||
fs.BoolVar(&watchIPNArgs.netmap, "netmap", true, "include netmap in messages")
|
||||
fs.BoolVar(&watchIPNArgs.initial, "initial", false, "include initial status")
|
||||
fs.BoolVar(&watchIPNArgs.showPrivateKey, "show-private-key", false, "include node private key in printed netmap")
|
||||
fs.IntVar(&watchIPNArgs.count, "count", 0, "exit after printing this many statuses, or 0 to keep going forever")
|
||||
return fs
|
||||
})(),
|
||||
},
|
||||
@ -416,6 +417,7 @@ func runPrefs(ctx context.Context, args []string) error {
|
||||
netmap bool
|
||||
initial bool
|
||||
showPrivateKey bool
|
||||
count int
|
||||
}
|
||||
|
||||
func runWatchIPN(ctx context.Context, args []string) error {
|
||||
@ -431,8 +433,8 @@ func runWatchIPN(ctx context.Context, args []string) error {
|
||||
return err
|
||||
}
|
||||
defer watcher.Close()
|
||||
printf("Connected.\n")
|
||||
for {
|
||||
fmt.Fprintf(os.Stderr, "Connected.\n")
|
||||
for seen := 0; watchIPNArgs.count == 0 || seen < watchIPNArgs.count; seen++ {
|
||||
n, err := watcher.Next()
|
||||
if err != nil {
|
||||
return err
|
||||
@ -441,8 +443,9 @@ func runWatchIPN(ctx context.Context, args []string) error {
|
||||
n.NetMap = nil
|
||||
}
|
||||
j, _ := json.MarshalIndent(n, "", "\t")
|
||||
printf("%s\n", j)
|
||||
fmt.Printf("%s\n", j)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func runDERPMap(ctx context.Context, args []string) error {
|
||||
|
Loading…
Reference in New Issue
Block a user