added exit status

This commit is contained in:
Mike Farah
2020-11-30 16:35:21 +11:00
parent 9bc66c80b6
commit c9229439f7
5 changed files with 24 additions and 3 deletions
+6 -1
View File
@@ -1,6 +1,7 @@
package cmd
import (
"errors"
"fmt"
"os"
@@ -24,6 +25,7 @@ yq es -n '{"a": "b"}'
return cmdEvalAll
}
func evaluateAll(cmd *cobra.Command, args []string) error {
cmd.SilenceUsage = true
// 0 args, read std in
// 1 arg, null input, process expression
// 1 arg, read file in sequence
@@ -81,6 +83,9 @@ func evaluateAll(cmd *cobra.Command, args []string) error {
completedSuccessfully = err == nil
cmd.SilenceUsage = true
if err == nil && exitStatus && !printer.PrintedAnything() {
return errors.New("no matches found")
}
return err
}