cmd: add a 'version' subcommand and flag to show the version
This commit is contained in:
@@ -5,6 +5,8 @@ import (
|
||||
"os"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"git.offline-twitter.com/offline-labs/gas-stack/pkg/version"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -16,12 +18,16 @@ const (
|
||||
func main() {
|
||||
root_cmd := &cobra.Command{
|
||||
Use: "gas",
|
||||
Version: version.String(),
|
||||
SilenceErrors: true,
|
||||
SilenceUsage: true,
|
||||
}
|
||||
// Print a bare version string ("v0.0.4"), rather than cobra's "gas version v0.0.4".
|
||||
root_cmd.SetVersionTemplate("{{.Version}}\n")
|
||||
root_cmd.AddCommand(sqlite_lint)
|
||||
root_cmd.AddCommand(cmd_init)
|
||||
root_cmd.AddCommand(generate_model)
|
||||
root_cmd.AddCommand(cmd_version)
|
||||
if err := root_cmd.Execute(); err != nil {
|
||||
fmt.Println(RED + err.Error() + RESET)
|
||||
os.Exit(1)
|
||||
|
||||
Reference in New Issue
Block a user