diff --git a/cmd/daemon/root.go b/cmd/daemon/root.go index b61def4..98f391f 100644 --- a/cmd/daemon/root.go +++ b/cmd/daemon/root.go @@ -52,6 +52,7 @@ func rootCmd() *cobra.Command { // Common flags verbose.AddAsFlag(cmd, true) // SubCommands + cmd.AddCommand(versionCmd()) cmd.AddCommand(run.RunCmd()) return cmd } diff --git a/cmd/daemon/version.go b/cmd/daemon/version.go new file mode 100644 index 0000000..092beb3 --- /dev/null +++ b/cmd/daemon/version.go @@ -0,0 +1,23 @@ +package daemon + +import ( + "fmt" + + "stamus-ctl/internal/app" + + "github.com/spf13/cobra" +) + +func printVersion() { + fmt.Printf("version: %s\narch: %s\ncommit: %s\n", app.Version, app.Arch, app.Commit) +} + +func versionCmd() *cobra.Command { + return &cobra.Command{ + Use: "version", + Short: "Version information", + Run: func(cmd *cobra.Command, args []string) { + printVersion() + }, + } +}