From f8f986972ba1b12c0946951cf5e436146350c341 Mon Sep 17 00:00:00 2001 From: Manohar Reddy Date: Sat, 1 Oct 2022 23:55:13 +0200 Subject: [PATCH 1/4] make blobberID field mandatory for sp-info command --- cmd/stakepool.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/cmd/stakepool.go b/cmd/stakepool.go index f38b97b9..01a53ce1 100644 --- a/cmd/stakepool.go +++ b/cmd/stakepool.go @@ -3,6 +3,7 @@ package cmd import ( "fmt" "log" + "os" "github.com/0chain/gosdk/zboxcore/sdk" "github.com/0chain/gosdk/zcncore" @@ -85,12 +86,13 @@ var spInfo = &cobra.Command{ doJSON, _ := cmd.Flags().GetBool("json") - if flags.Changed("blobber_id") { - if blobberID, err = flags.GetString("blobber_id"); err != nil { - log.Fatalf("can't get 'blobber_id' flag: %v", err) - } + if !flags.Changed("blobber_id") { + PrintError("Error: blobber_id flag is missing") + os.Exit(1) } + blobberID = cmd.Flag("blobber_id").Value.String() + var info *sdk.StakePoolInfo if info, err = sdk.GetStakePoolInfo(blobberID); err != nil { log.Fatalf("Failed to get stake pool info: %v", err) @@ -267,7 +269,7 @@ func init() { rootCmd.AddCommand(spUnlock) spInfo.PersistentFlags().String("blobber_id", "", - "for given blobber, default is current client") + "for given blobber") spInfo.PersistentFlags().Bool("json", false, "pass this option to print response as json data") spUserInfo.PersistentFlags().Bool("json", false, "pass this option to print response as json data") From 872d9b3a2bde6e24c886c0435067fc59b8799ce4 Mon Sep 17 00:00:00 2001 From: boddumanohar Date: Thu, 13 Oct 2022 08:20:01 +0200 Subject: [PATCH 2/4] Update cmd/stakepool.go Co-authored-by: Lz --- cmd/stakepool.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/stakepool.go b/cmd/stakepool.go index 01a53ce1..1394f780 100644 --- a/cmd/stakepool.go +++ b/cmd/stakepool.go @@ -91,7 +91,7 @@ var spInfo = &cobra.Command{ os.Exit(1) } - blobberID = cmd.Flag("blobber_id").Value.String() + blobberID = flags.GetString("blobber_id") var info *sdk.StakePoolInfo if info, err = sdk.GetStakePoolInfo(blobberID); err != nil { From df43ac7f481fc32d3ea6cd5d97bd46ad758cab4d Mon Sep 17 00:00:00 2001 From: boddumanohar Date: Thu, 13 Oct 2022 08:20:11 +0200 Subject: [PATCH 3/4] Update cmd/stakepool.go Co-authored-by: Lz --- cmd/stakepool.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/stakepool.go b/cmd/stakepool.go index 1394f780..a1f0443a 100644 --- a/cmd/stakepool.go +++ b/cmd/stakepool.go @@ -87,7 +87,7 @@ var spInfo = &cobra.Command{ doJSON, _ := cmd.Flags().GetBool("json") if !flags.Changed("blobber_id") { - PrintError("Error: blobber_id flag is missing") + log.Fatalf("Error: blobber_id flag is missing") os.Exit(1) } From 0028213e2283d32850f14d7da7d4d31b4cfa0df7 Mon Sep 17 00:00:00 2001 From: Manohar Reddy Date: Thu, 13 Oct 2022 22:33:29 +0200 Subject: [PATCH 4/4] fix uts --- cmd/stakepool.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cmd/stakepool.go b/cmd/stakepool.go index a1f0443a..e24510c8 100644 --- a/cmd/stakepool.go +++ b/cmd/stakepool.go @@ -3,7 +3,6 @@ package cmd import ( "fmt" "log" - "os" "github.com/0chain/gosdk/zboxcore/sdk" "github.com/0chain/gosdk/zcncore" @@ -88,10 +87,12 @@ var spInfo = &cobra.Command{ if !flags.Changed("blobber_id") { log.Fatalf("Error: blobber_id flag is missing") - os.Exit(1) } - blobberID = flags.GetString("blobber_id") + blobberID, err = flags.GetString("blobber_id") + if err != nil { + log.Fatalf("Error: cannot get the value of blobber_id") + } var info *sdk.StakePoolInfo if info, err = sdk.GetStakePoolInfo(blobberID); err != nil {