feat(hubl): add version command (#16530)
This commit is contained in:
parent
a6bf0ab23d
commit
ad1c5794dc
@ -4,7 +4,7 @@ go 1.20
|
||||
|
||||
require (
|
||||
cosmossdk.io/api v0.4.2
|
||||
cosmossdk.io/client/v2 v2.0.0-20230607190716-2877190997a2
|
||||
cosmossdk.io/client/v2 v2.0.0-20230613135102-afe571f5b616
|
||||
cosmossdk.io/errors v1.0.0-beta.7.0.20230524212735-6cabb6aa5741
|
||||
github.com/cockroachdb/errors v1.10.0
|
||||
github.com/cosmos/cosmos-sdk v0.50.0-alpha.0
|
||||
|
||||
@ -37,8 +37,8 @@ cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9
|
||||
cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo=
|
||||
cosmossdk.io/api v0.4.2 h1:lQBMl4xINnMnBOR/tQLtjlDnR4exr4e6/SfHR8PILE0=
|
||||
cosmossdk.io/api v0.4.2/go.mod h1:qrVgOp7DIeAXa+Tt5dDjOC47bZCDrwx8ZHxrmy7STNE=
|
||||
cosmossdk.io/client/v2 v2.0.0-20230607190716-2877190997a2 h1:x4eu8xjihip1U+WCuOrK3rcyMSe28HS9D8ZPyoONrcE=
|
||||
cosmossdk.io/client/v2 v2.0.0-20230607190716-2877190997a2/go.mod h1:Khq/WZqGHSgFlwPI6Ui47UE9RzblIze7iMX+s3nu3eM=
|
||||
cosmossdk.io/client/v2 v2.0.0-20230613135102-afe571f5b616 h1:/rT+NrbfwF4/Fe0pgSdAejUOmgItfP40w+Vg2Zub92o=
|
||||
cosmossdk.io/client/v2 v2.0.0-20230613135102-afe571f5b616/go.mod h1:55KO/mJnklKWaDVQn5Q126IsbenPosRBUFRDpr5TQr8=
|
||||
cosmossdk.io/collections v0.2.0 h1:CgMfLtE16+qox3zBYrGh60i4yKV8SeExLnIdOS2sbQs=
|
||||
cosmossdk.io/collections v0.2.0/go.mod h1:Oc1FK0vlmxJZsgUn9/o3ldE6zNyWKvobVzaLhWknZJE=
|
||||
cosmossdk.io/core v0.8.0 h1:LcJnu52E1a8f8E317VfQ1xK/RZe+IuhMNQAjnDLh25M=
|
||||
|
||||
@ -24,6 +24,7 @@ var (
|
||||
flagInsecure = "insecure"
|
||||
flagUpdate = "update"
|
||||
flagConfig = "config"
|
||||
flagLong = "long"
|
||||
)
|
||||
|
||||
func RootCommand() (*cobra.Command, error) {
|
||||
@ -49,7 +50,11 @@ func RootCommand() (*cobra.Command, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
commands = append(commands, InitCommand(config, configDir))
|
||||
commands = append(
|
||||
commands,
|
||||
InitCommand(config, configDir),
|
||||
VersionCmd(),
|
||||
)
|
||||
|
||||
cmd.AddCommand(commands...)
|
||||
return cmd, nil
|
||||
|
||||
40
tools/hubl/internal/version.go
Normal file
40
tools/hubl/internal/version.go
Normal file
@ -0,0 +1,40 @@
|
||||
package internal
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"runtime/debug"
|
||||
"strings"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func VersionCmd() *cobra.Command {
|
||||
var long bool
|
||||
|
||||
versionCmd := &cobra.Command{
|
||||
Use: "version",
|
||||
Short: "Display hubl version",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
version, ok := debug.ReadBuildInfo()
|
||||
if !ok {
|
||||
return fmt.Errorf("failed to get hubl version")
|
||||
}
|
||||
|
||||
cmd.Printf("hubl version: %s\n", strings.TrimSpace(version.Main.Version))
|
||||
|
||||
if long {
|
||||
for _, dep := range version.Deps {
|
||||
if dep.Path == "cosmossdk.io/client/v2" {
|
||||
cmd.Printf("client/v2 version: %s\n", strings.TrimSpace(dep.Version))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
versionCmd.Flags().BoolVar(&long, flagLong, false, "display long version information")
|
||||
|
||||
return versionCmd
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user