buildr/internal/cmd/version.go

26 lines
486 B
Go
Raw Normal View History

2023-04-11 20:30:48 +00:00
package cmd
import (
"log/slog"
2023-04-11 20:30:48 +00:00
"runtime"
"github.com/spf13/cobra"
)
var CurrentVersion = "development"
2023-04-11 20:30:48 +00:00
func VersionCommand() *cobra.Command {
return &cobra.Command{
2023-04-11 20:30:48 +00:00
Use: "version",
Short: "Prints the version of the CLI",
2023-04-11 20:30:48 +00:00
SilenceUsage: true,
SilenceErrors: true,
Run: func(*cobra.Command, []string) {
slog.Info("BuildR version",
slog.String("current_version", CurrentVersion),
slog.String("go_version", runtime.Version()),
)
},
2023-04-11 20:30:48 +00:00
}
}