3
0

Add version cli command

This commit is contained in:
Denis Arh
2020-03-16 08:54:30 +01:00
parent 700fae5e00
commit 47db9e7ab9
2 changed files with 18 additions and 0 deletions
+1
View File
@@ -302,6 +302,7 @@ func (r *runner) Run(ctx context.Context) error {
serveCmd,
upgradeCmd,
provisionCmd,
cli.VersionCommand(),
)
// Register CLI commands from all parts (when compatible)
+17
View File
@@ -1,6 +1,7 @@
package cli
import (
"github.com/cortezaproject/corteza-server/pkg/version"
"github.com/spf13/cobra"
)
@@ -27,6 +28,11 @@ var (
Use: "provision",
Short: "Provision tasks",
}
versionCommand = cobra.Command{
Use: "version",
Short: "Version",
}
)
// RootCommand creates root command with a simple persistent-pre-run callback
@@ -80,3 +86,14 @@ func ProvisionCommand(cffn func() error) *cobra.Command {
return &cfCmd
}
func VersionCommand() *cobra.Command {
// Make a copies
var cfCmd = versionCommand
cfCmd.Run = func(cmd *cobra.Command, args []string) {
cmd.Println(version.Version)
}
return &cfCmd
}