Skip to content

Commit

Permalink
added version flag to cli
Browse files Browse the repository at this point in the history
  • Loading branch information
ascandone committed Jul 26, 2024
1 parent 7a941f8 commit 7b4292c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
10 changes: 8 additions & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,22 @@ import (
"github.com/spf13/cobra"
)

type CliOptions struct {
Version string
}

var rootCmd = &cobra.Command{
Use: "numscript",
Short: "Numscript cli", // TODO better descr
Short: "Numscript cli",
Long: "Numscript cli",
CompletionOptions: cobra.CompletionOptions{
DisableDefaultCmd: true,
},
}

func Execute() {
func Execute(options CliOptions) {
rootCmd.Version = options.Version

rootCmd.AddCommand(lspCmd)
rootCmd.AddCommand(checkCmd)

Expand Down
4 changes: 3 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,7 @@ func main() {
defer recoverPanic()
defer sentry.Flush(2 * time.Second)

cmd.Execute()
cmd.Execute(cmd.CliOptions{
Version: Version,
})
}

0 comments on commit 7b4292c

Please sign in to comment.