Added default value flag - for printing out a value when reading and there are no matches

This commit is contained in:
Mike Farah
2020-02-03 10:13:48 +11:00
parent f52de57652
commit 699fce9da4
4 changed files with 19 additions and 0 deletions
+3
View File
@@ -104,6 +104,9 @@ func updateStyleOfNode(node *yaml.Node, style yaml.Style) {
func printResults(matchingNodes []*yqlib.NodeContext, cmd *cobra.Command) error {
if len(matchingNodes) == 0 {
log.Debug("no matching results, nothing to print")
if defaultValue != "" {
cmd.Print(defaultValue)
}
return nil
}