File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -47,10 +47,13 @@ const (
4747 envPrefix = "BOOTLOG"
4848)
4949
50- // Version is set during the build process using the -ldflags option.
50+ // Ver (version) is set during the build process using the -ldflags option.
5151// If not set, it defaults to "unknown".
5252var Ver string = "unknown"
5353
54+ // Date of build for use with the version command
55+ var BuildDate string = "unknown"
56+
5457// rootCmd represents the base command when called without any subcommands
5558var rootCmd = & cobra.Command {
5659 Use : "bootlogger" ,
Original file line number Diff line number Diff line change @@ -34,13 +34,16 @@ var versionCmd = &cobra.Command{
3434 Short : "Print the bootlogger version number to the console." ,
3535 Example : " bootlogger version\n bootlogger ver" ,
3636 Run : func (cmd * cobra.Command , args []string ) {
37- color .New (color .FgHiWhite ).Printf ("bootlogger version:" )
37+ color .New (color .FgHiWhite ).Printf ("version:" )
3838 if Ver == "unknown" {
3939 color .New (color .FgHiRed ).Printf (" Version was not set during build.\n " )
40- } else {
41- color .New (color .FgHiGreen ).Printf (" %s\n " , Ver )
40+ return
41+ }
42+ color .New (color .FgHiGreen ).Printf (" %s\n " , Ver )
43+ if BuildDate != "unknown" {
44+ color .New (color .FgHiWhite ).Printf ("build date:" )
45+ color .New (color .FgHiGreen ).Printf (" %s\n " , BuildDate )
4246 }
43-
4447 },
4548}
4649
You can’t perform that action at this time.
0 commit comments