Skip to content

Commit

Permalink
make blobberID field mandatory for sp-info command
Browse files Browse the repository at this point in the history
  • Loading branch information
boddumanohar committed Oct 10, 2022
1 parent f8f6e08 commit f8f9869
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions cmd/stakepool.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package cmd
import (
"fmt"
"log"
"os"

"github.com/0chain/gosdk/zboxcore/sdk"
"github.com/0chain/gosdk/zcncore"
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit f8f9869

Please sign in to comment.