Skip to content

Commit 7b4292c

Browse files
committed
added version flag to cli
1 parent 7a941f8 commit 7b4292c

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

cmd/root.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,22 @@ import (
77
"github.com/spf13/cobra"
88
)
99

10+
type CliOptions struct {
11+
Version string
12+
}
13+
1014
var rootCmd = &cobra.Command{
1115
Use: "numscript",
12-
Short: "Numscript cli", // TODO better descr
16+
Short: "Numscript cli",
1317
Long: "Numscript cli",
1418
CompletionOptions: cobra.CompletionOptions{
1519
DisableDefaultCmd: true,
1620
},
1721
}
1822

19-
func Execute() {
23+
func Execute(options CliOptions) {
24+
rootCmd.Version = options.Version
25+
2026
rootCmd.AddCommand(lspCmd)
2127
rootCmd.AddCommand(checkCmd)
2228

main.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,7 @@ func main() {
3535
defer recoverPanic()
3636
defer sentry.Flush(2 * time.Second)
3737

38-
cmd.Execute()
38+
cmd.Execute(cmd.CliOptions{
39+
Version: Version,
40+
})
3941
}

0 commit comments

Comments
 (0)