Skip to content

Commit

Permalink
feat: Support only print the version number (#265)
Browse files Browse the repository at this point in the history
Signed-off-by: terrytangyuan <terrytangyuan@gmail.com>
  • Loading branch information
terrytangyuan authored Jun 11, 2022
1 parent 5e82ccb commit 846dc0e
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion pkg/app/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,23 @@ var CommandVersion = &cli.Command{
Aliases: []string{"v"},
Usage: "Print envd version information",
Action: printVersion,
Flags: []cli.Flag{
&cli.BoolFlag{
Name: "short",
Usage: "Only print the version number",
Value: false,
Aliases: []string{"s"},
},
},
}

func printVersion(*cli.Context) error {
func printVersion(ctx *cli.Context) error {
short := ctx.Bool("short")
ver := version.GetVersion()
fmt.Printf("envd: %s\n", ver)
if short {
return nil
}
fmt.Printf(" BuildDate: %s\n", ver.BuildDate)
fmt.Printf(" GitCommit: %s\n", ver.GitCommit)
fmt.Printf(" GitTreeState: %s\n", ver.GitTreeState)
Expand Down

0 comments on commit 846dc0e

Please sign in to comment.