Skip to content

Commit

Permalink
Use cobra's version flag support
Browse files Browse the repository at this point in the history
Assigning a value to the Version field in the root cobra command
automatically defines a --version flag which displays the command name
and version, in much the same way as "subctl version" does already.
This provides version information in a fashion aligned with common
practice.

Signed-off-by: Stephen Kitt <[email protected]>
  • Loading branch information
skitt committed Sep 20, 2024
1 parent bf332e0 commit dcc1a1a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions cmd/subctl/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
"github.com/submariner-io/shipyard/test/e2e/framework"
"github.com/submariner-io/subctl/internal/exit"
"github.com/submariner-io/subctl/pkg/cluster"
"github.com/submariner-io/subctl/pkg/version"
submarineropv1a1 "github.com/submariner-io/submariner-operator/api/v1alpha1"
submarinerv1 "github.com/submariner-io/submariner/pkg/apis/submariner.io/v1"
"golang.org/x/net/http/httpproxy"
Expand Down Expand Up @@ -64,8 +65,9 @@ func init() {

// rootCmd represents the base command when called without any subcommands.
var rootCmd = &cobra.Command{
Use: filepath.Base(os.Args[0]),
Short: "Deploy, manage, verify and diagnose Submariner deployments",
Use: filepath.Base(os.Args[0]),
Short: "Deploy, manage, verify and diagnose Submariner deployments",
Version: version.Version,
}

// Execute adds all child commands to the root command and sets flags appropriately.
Expand Down

0 comments on commit dcc1a1a

Please sign in to comment.