Skip to content

Commit 5dbf449

Browse files
committed
fix(daemon): added version subcommand
1 parent fb2af2d commit 5dbf449

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

cmd/daemon/root.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ func rootCmd() *cobra.Command {
5252
// Common flags
5353
verbose.AddAsFlag(cmd, true)
5454
// SubCommands
55+
cmd.AddCommand(versionCmd())
5556
cmd.AddCommand(run.RunCmd())
5657
return cmd
5758
}

cmd/daemon/version.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package daemon
2+
3+
import (
4+
"fmt"
5+
6+
"stamus-ctl/internal/app"
7+
8+
"github.com/spf13/cobra"
9+
)
10+
11+
func printVersion() {
12+
fmt.Printf("version: %s\narch: %s\ncommit: %s\n", app.Version, app.Arch, app.Commit)
13+
}
14+
15+
func versionCmd() *cobra.Command {
16+
return &cobra.Command{
17+
Use: "version",
18+
Short: "Version information",
19+
Run: func(cmd *cobra.Command, args []string) {
20+
printVersion()
21+
},
22+
}
23+
}

0 commit comments

Comments
 (0)