From 1e85b1cb5f4d97343eac430fd6b28c621b97e6ba Mon Sep 17 00:00:00 2001 From: Cole Helbling Date: Sun, 14 Mar 2021 17:49:55 -0700 Subject: [PATCH] client/status: allow raw mode without a tty A fairly common pattern when presented with JSON is to pipe it to `jq`. This also allows one to `zrepl status --mode raw > log` and operate on the JSON there. closes #442 --- client/status/status.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/client/status/status.go b/client/status/status.go index 5016017..0ff0368 100644 --- a/client/status/status.go +++ b/client/status/status.go @@ -71,12 +71,16 @@ func runStatusV2Command(ctx context.Context, config *config.Config, args []strin mode := statusv2Flags.Mode.Value().(statusv2Mode) - if !isatty.IsTerminal(os.Stdout.Fd()) && mode != StatusV2ModeDump { - usemode, err := statusv2Flags.Mode.InputForChoice(StatusV2ModeDump) + if !isatty.IsTerminal(os.Stdout.Fd()) && mode != StatusV2ModeDump && mode != StatusV2ModeRaw { + dumpmode, err := statusv2Flags.Mode.InputForChoice(StatusV2ModeDump) if err != nil { panic(err) } - return errors.Errorf("error: stdout is not a tty, please use --mode %s", usemode) + rawmode, err := statusv2Flags.Mode.InputForChoice(StatusV2ModeRaw) + if err != nil { + panic(err) + } + return errors.Errorf("error: stdout is not a tty, please use --mode %s or --mode %s", dumpmode, rawmode) } switch mode {