diff --git a/pkg/app/runner.go b/pkg/app/runner.go index 03c415ce6..bb4a3d6ec 100644 --- a/pkg/app/runner.go +++ b/pkg/app/runner.go @@ -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) diff --git a/pkg/cli/commands.go b/pkg/cli/commands.go index eddecc3f8..90e5448ad 100644 --- a/pkg/cli/commands.go +++ b/pkg/cli/commands.go @@ -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 +}