mirror of
https://github.com/zrepl/zrepl.git
synced 2024-11-21 16:03:32 +01:00
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
This commit is contained in:
parent
5c6d69a69c
commit
1e85b1cb5f
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user