From 67981d8f9a5241ddb710c51b0cf603799c46df4a Mon Sep 17 00:00:00 2001 From: Christian Richter Date: Wed, 3 Dec 2025 15:10:53 +0100 Subject: [PATCH] refactor version cli command from urfave/cli to spf13/cobra Signed-off-by: Christian Richter --- opencloud/pkg/command/version.go | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/opencloud/pkg/command/version.go b/opencloud/pkg/command/version.go index beb39d686d..39fd6cc748 100644 --- a/opencloud/pkg/command/version.go +++ b/opencloud/pkg/command/version.go @@ -4,15 +4,15 @@ import ( "fmt" "os" - "github.com/olekukonko/tablewriter" - "github.com/olekukonko/tablewriter/tw" - "github.com/urfave/cli/v2" - mreg "go-micro.dev/v4/registry" - "github.com/opencloud-eu/opencloud/opencloud/pkg/register" "github.com/opencloud-eu/opencloud/pkg/config" "github.com/opencloud-eu/opencloud/pkg/registry" "github.com/opencloud-eu/opencloud/pkg/version" + "github.com/spf13/cobra" + + "github.com/olekukonko/tablewriter" + "github.com/olekukonko/tablewriter/tw" + mreg "go-micro.dev/v4/registry" ) const ( @@ -20,23 +20,16 @@ const ( ) // VersionCommand is the entrypoint for the version command. -func VersionCommand(cfg *config.Config) *cli.Command { - return &cli.Command{ - Name: "version", - Usage: "print the version of this binary and all running service instances", - Flags: []cli.Flag{ - &cli.BoolFlag{ - Name: _skipServiceListingFlagName, - Usage: "skip service listing", - }, - }, - Category: "info", - Action: func(c *cli.Context) error { +func VersionCommand(cfg *config.Config) *cobra.Command { + versionCmd := &cobra.Command{ + Use: "version", + Short: "print the version of this binary and all running service instances", + RunE: func(cmd *cobra.Command, args []string) error { fmt.Println("Version: " + version.GetString()) fmt.Printf("Edition: %s\n", version.Edition) fmt.Printf("Compiled: %s\n", version.Compiled()) - if c.Bool(_skipServiceListingFlagName) { + if cmd.Flag(_skipServiceListingFlagName).Changed { return nil } @@ -75,6 +68,8 @@ func VersionCommand(cfg *config.Config) *cli.Command { return nil }, } + versionCmd.Flags().Bool(_skipServiceListingFlagName, false, "skip service listing") + return versionCmd } func init() {