1
0
mirror of https://github.com/taigrr/yq synced 2025-01-18 04:53:17 -08:00

Compare commits

..

4 Commits

Author SHA1 Message Date
Mike Farah
f42355cf9f Force re-release 2021-02-10 17:12:54 +11:00
Mike Farah
44bc9971c1 Fixed write-inplace with no expression 2021-02-10 17:06:16 +11:00
Ben Moss
54cf6cf282 Fix pretty-printing
Fixes #716 #715
2021-02-10 16:56:44 +11:00
Mike Farah
29db5ebf4d Version increment 2021-02-10 16:55:05 +11:00
6 changed files with 23 additions and 8 deletions

View File

@@ -42,14 +42,21 @@ func evaluateAll(cmd *cobra.Command, args []string) error {
colorsEnabled = true colorsEnabled = true
} }
if writeInplace && len(args) < 2 { firstFileIndex := -1
if !nullInput && len(args) == 1 {
firstFileIndex = 0
} else if len(args) > 1 {
firstFileIndex = 1
}
if writeInplace && (firstFileIndex == -1) {
return fmt.Errorf("Write inplace flag only applicable when giving an expression and at least one file") return fmt.Errorf("Write inplace flag only applicable when giving an expression and at least one file")
} }
if writeInplace { if writeInplace {
// only use colors if its forced // only use colors if its forced
colorsEnabled = forceColor colorsEnabled = forceColor
writeInPlaceHandler := yqlib.NewWriteInPlaceHandler(args[1]) writeInPlaceHandler := yqlib.NewWriteInPlaceHandler(args[firstFileIndex])
out, err = writeInPlaceHandler.CreateTempFile() out, err = writeInPlaceHandler.CreateTempFile()
if err != nil { if err != nil {
return err return err

View File

@@ -62,14 +62,21 @@ func evaluateSequence(cmd *cobra.Command, args []string) error {
colorsEnabled = true colorsEnabled = true
} }
if writeInplace && len(args) < 2 { firstFileIndex := -1
if !nullInput && len(args) == 1 {
firstFileIndex = 0
} else if len(args) > 1 {
firstFileIndex = 1
}
if writeInplace && (firstFileIndex == -1) {
return fmt.Errorf("Write inplace flag only applicable when giving an expression and at least one file") return fmt.Errorf("Write inplace flag only applicable when giving an expression and at least one file")
} }
if writeInplace { if writeInplace {
// only use colors if its forced // only use colors if its forced
colorsEnabled = forceColor colorsEnabled = forceColor
writeInPlaceHandler := yqlib.NewWriteInPlaceHandler(args[1]) writeInPlaceHandler := yqlib.NewWriteInPlaceHandler(args[firstFileIndex])
out, err = writeInPlaceHandler.CreateTempFile() out, err = writeInPlaceHandler.CreateTempFile()
if err != nil { if err != nil {
return err return err
@@ -102,7 +109,7 @@ func evaluateSequence(cmd *cobra.Command, args []string) error {
err = streamEvaluator.EvaluateFiles(processExpression(""), []string{args[0]}, printer) err = streamEvaluator.EvaluateFiles(processExpression(""), []string{args[0]}, printer)
} }
default: default:
err = streamEvaluator.EvaluateFiles(args[0], args[1:], printer) err = streamEvaluator.EvaluateFiles(processExpression(args[0]), args[1:], printer)
} }
completedSuccessfully = err == nil completedSuccessfully = err == nil

View File

@@ -11,7 +11,7 @@ var (
GitDescribe string GitDescribe string
// Version is main version number that is being run at the moment. // Version is main version number that is being run at the moment.
Version = "4.5.0" Version = "4.5.1"
// VersionPrerelease is a pre-release marker for the version. If this is "" (empty string) // VersionPrerelease is a pre-release marker for the version. If this is "" (empty string)
// then it means that it is a final release. Otherwise, this is a pre-release // then it means that it is a final release. Otherwise, this is a pre-release

View File

@@ -1,4 +1,4 @@
FROM mikefarah/yq:4.5.0 FROM mikefarah/yq:4.5.1
COPY entrypoint.sh /entrypoint.sh COPY entrypoint.sh /entrypoint.sh

View File

@@ -8,6 +8,7 @@
- use github actions to publish docker and make github release - use github actions to publish docker and make github release
- check github updated yq action in marketplace - check github updated yq action in marketplace
- snapcraft - snapcraft
- will auto create a candidate, test it works then promote - will auto create a candidate, test it works then promote

View File

@@ -1,5 +1,5 @@
name: yq name: yq
version: '4.5.0' version: '4.5.1'
summary: A lightweight and portable command-line YAML processor summary: A lightweight and portable command-line YAML processor
description: | description: |
The aim of the project is to be the jq or sed of yaml files. The aim of the project is to be the jq or sed of yaml files.