From 354fd6cf34bfa908f2d9796de5b1ff955b060ca6 Mon Sep 17 00:00:00 2001 From: Vincent Batts Date: Sun, 26 Jun 2016 10:15:12 -0400 Subject: [PATCH] cmd: add a `disasm --no-stdout` flag Since sometimes you just need to > /dev/null Signed-off-by: Vincent Batts --- cmd/tar-split/disasm.go | 9 ++++++++- cmd/tar-split/main.go | 4 ++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/cmd/tar-split/disasm.go b/cmd/tar-split/disasm.go index b7b0dfe..7f8a056 100644 --- a/cmd/tar-split/disasm.go +++ b/cmd/tar-split/disasm.go @@ -3,6 +3,7 @@ package main import ( "compress/gzip" "io" + "io/ioutil" "os" "github.com/Sirupsen/logrus" @@ -48,7 +49,13 @@ func CommandDisasm(c *cli.Context) { if err != nil { logrus.Fatal(err) } - i, err := io.Copy(os.Stdout, its) + var out io.Writer + if c.Bool("no-stdout") { + out = ioutil.Discard + } else { + out = os.Stdout + } + i, err := io.Copy(out, its) if err != nil { logrus.Fatal(err) } diff --git a/cmd/tar-split/main.go b/cmd/tar-split/main.go index b417120..c584352 100644 --- a/cmd/tar-split/main.go +++ b/cmd/tar-split/main.go @@ -42,6 +42,10 @@ func main() { Value: "tar-data.json.gz", Usage: "output of disassembled tar stream", }, + cli.BoolFlag{ + Name: "no-stdout", + Usage: "do not throughput the stream to STDOUT", + }, }, }, {