From e87a716b30a1433c73ac259812a8b0926847b088 Mon Sep 17 00:00:00 2001 From: Taco de Wolff Date: Mon, 31 Jul 2023 11:16:49 +0200 Subject: [PATCH] cmd: allow use of dash `-` for source/destination to mean stdin/stdout --- cmd/minify/main.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cmd/minify/main.go b/cmd/minify/main.go index c0b92f0ef1..d8bd443075 100644 --- a/cmd/minify/main.go +++ b/cmd/minify/main.go @@ -191,6 +191,11 @@ func run() int { return 1 } inputs := f.Args() + if len(inputs) == 1 && inputs[0] == "-" { + inputs = inputs[:0] + } else if output == "-" { + output = "" + } useStdin := len(inputs) == 0 Error = log.New(ioutil.Discard, "", 0) @@ -345,6 +350,10 @@ func run() int { //////////////// for i, input := range inputs { + if input == "-" { + Error.Println("cannot mix files and stdin as input") + return 1 + } inputs[i] = filepath.Clean(input) if input[len(input)-1] == '/' { inputs[i] += "/"