mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-11 17:12:51 +00:00
@@ -59,18 +59,28 @@ func getVersion() version {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Print prints version.
|
// Print prints version.
|
||||||
func (v version) Print(w io.Writer) {
|
func (v version) Print(w io.Writer, short bool) {
|
||||||
|
if short {
|
||||||
|
fmt.Fprintf(w, "%s\n", v.KustomizeVersion)
|
||||||
|
} else {
|
||||||
fmt.Fprintf(w, "Version: %+v\n", v)
|
fmt.Fprintf(w, "Version: %+v\n", v)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// NewCmdVersion makes version command.
|
// NewCmdVersion makes version command.
|
||||||
func NewCmdVersion(w io.Writer) *cobra.Command {
|
func NewCmdVersion(w io.Writer) *cobra.Command {
|
||||||
return &cobra.Command{
|
var short bool
|
||||||
|
|
||||||
|
versionCmd := cobra.Command{
|
||||||
Use: "version",
|
Use: "version",
|
||||||
Short: "Prints the kustomize version",
|
Short: "Prints the kustomize version",
|
||||||
Example: `kustomize version`,
|
Example: `kustomize version`,
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
getVersion().Print(w)
|
getVersion().Print(w, short)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
versionCmd.Flags().BoolVar(&short, "short", false, "print just the version number")
|
||||||
|
return &versionCmd
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user