mirror of
https://github.com/mikefarah/yq.git
synced 2024-12-19 20:19:04 +00:00
Pretty print everything
This commit is contained in:
parent
166f866f28
commit
bfc1a621c4
@ -114,6 +114,7 @@ Available Commands:
|
||||
|
||||
Flags:
|
||||
-h, --help help for yq
|
||||
-P, --prettyPrint pretty print
|
||||
-j, --tojson output as json
|
||||
-v, --verbose verbose mode
|
||||
-V, --version Print version information and quit
|
||||
|
@ -26,7 +26,6 @@ yq x -d1 dataA.yaml dataB.yaml 'a.b.c'
|
||||
}
|
||||
cmdCompare.PersistentFlags().StringVarP(&docIndex, "doc", "d", "0", "process document index number (0 based, * for all documents)")
|
||||
cmdCompare.PersistentFlags().StringVarP(&printMode, "printMode", "p", "v", "print mode (v (values, default), p (paths), pv (path and value pairs)")
|
||||
cmdCompare.PersistentFlags().BoolVarP(&prettyPrint, "prettyPrint", "P", false, "pretty(ish) print")
|
||||
cmdCompare.PersistentFlags().StringVarP(&defaultValue, "defaultValue", "D", "", "default value printed when there are no results")
|
||||
return cmdCompare
|
||||
}
|
||||
|
@ -25,7 +25,6 @@ yq r -- things.yaml '--key-starting-with-dashes.blah'
|
||||
}
|
||||
cmdRead.PersistentFlags().StringVarP(&docIndex, "doc", "d", "0", "process document index number (0 based, * for all documents)")
|
||||
cmdRead.PersistentFlags().StringVarP(&printMode, "printMode", "p", "v", "print mode (v (values, default), p (paths), pv (path and value pairs)")
|
||||
cmdRead.PersistentFlags().BoolVarP(&prettyPrint, "prettyPrint", "P", false, "pretty(ish) print")
|
||||
cmdRead.PersistentFlags().StringVarP(&defaultValue, "defaultValue", "D", "", "default value printed when there are no results")
|
||||
return cmdRead
|
||||
}
|
||||
|
@ -40,6 +40,7 @@ func New() *cobra.Command {
|
||||
|
||||
rootCmd.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, "verbose mode")
|
||||
rootCmd.PersistentFlags().BoolVarP(&outputToJSON, "tojson", "j", false, "output as json")
|
||||
rootCmd.PersistentFlags().BoolVarP(&prettyPrint, "prettyPrint", "P", false, "pretty print")
|
||||
rootCmd.Flags().BoolVarP(&version, "version", "V", false, "Print version information and quit")
|
||||
|
||||
rootCmd.AddCommand(
|
||||
|
@ -201,6 +201,10 @@ func mapYamlDecoder(updateData updateDataFn, encoder yqlib.Encoder) yamlDecoderF
|
||||
return errors.Wrapf(errorUpdating, "Error updating document at index %v", currentIndex)
|
||||
}
|
||||
|
||||
if prettyPrint {
|
||||
updateStyleOfNode(&dataBucket, 0)
|
||||
}
|
||||
|
||||
errorWriting = encoder.Encode(&dataBucket)
|
||||
|
||||
if errorWriting != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user