mirror of
https://github.com/mudler/luet.git
synced 2025-07-18 09:21:13 +00:00
cmd/tree/bump: Add --to-stdout option
This commit is contained in:
parent
07e78dd89b
commit
42d1ec5585
@ -41,6 +41,7 @@ func NewTreeBumpCommand() *cobra.Command {
|
|||||||
},
|
},
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
spec, _ := cmd.Flags().GetString("definition-file")
|
spec, _ := cmd.Flags().GetString("definition-file")
|
||||||
|
toStdout, _ := cmd.Flags().GetBool("to-stdout")
|
||||||
pack, err := tree.ReadDefinitionFile(spec)
|
pack, err := tree.ReadDefinitionFile(spec)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
Fatal(err.Error())
|
Fatal(err.Error())
|
||||||
@ -52,16 +53,26 @@ func NewTreeBumpCommand() *cobra.Command {
|
|||||||
Fatal("Error on increment build version: " + err.Error())
|
Fatal("Error on increment build version: " + err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
err = tree.WriteDefinitionFile(&pack, spec)
|
if toStdout {
|
||||||
if err != nil {
|
data, err := pack.Yaml()
|
||||||
Fatal("Error on write definition file: " + err.Error())
|
if err != nil {
|
||||||
}
|
Fatal("Error on yaml conversion: " + err.Error())
|
||||||
|
}
|
||||||
|
fmt.Println(string(data))
|
||||||
|
} else {
|
||||||
|
|
||||||
fmt.Printf("Bumped package %s/%s-%s.\n", pack.Category, pack.Name, pack.Version)
|
err = tree.WriteDefinitionFile(&pack, spec)
|
||||||
|
if err != nil {
|
||||||
|
Fatal("Error on write definition file: " + err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Printf("Bumped package %s/%s-%s.\n", pack.Category, pack.Name, pack.Version)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
ans.Flags().StringP("definition-file", "f", "", "Path of the definition to bump.")
|
ans.Flags().StringP("definition-file", "f", "", "Path of the definition to bump.")
|
||||||
|
ans.Flags().BoolP("to-stdout", "o", false, "Bump package to output.")
|
||||||
|
|
||||||
return ans
|
return ans
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user