Make store name for query account configurable
This commit is contained in:
parent
c7ca6ec038
commit
7779eec990
|
@ -37,9 +37,13 @@ func main() {
|
|||
|
||||
// query/post commands (custom to binary)
|
||||
basecliCmd.AddCommand(
|
||||
client.GetCommands(bankcmd.GetAccountCmd())...)
|
||||
client.GetCommands(
|
||||
bankcmd.GetAccountCmd("main"),
|
||||
)...)
|
||||
basecliCmd.AddCommand(
|
||||
client.PostCommands(bankcmd.SendTxCommand())...)
|
||||
client.PostCommands(
|
||||
bankcmd.SendTxCommand(),
|
||||
)...)
|
||||
|
||||
// add proxy, version and key info
|
||||
basecliCmd.AddCommand(
|
||||
|
|
|
@ -19,16 +19,21 @@ import (
|
|||
|
||||
// GetAccountCmd returns a query account that will display the
|
||||
// state of the account at a given address
|
||||
func GetAccountCmd() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
func GetAccountCmd(storeName string) *cobra.Command {
|
||||
cmd := acctCmd{storeName}
|
||||
|
||||
return &cobra.Command{
|
||||
Use: "account <address>",
|
||||
Short: "Query account balance",
|
||||
RunE: getAccount,
|
||||
RunE: cmd.get,
|
||||
}
|
||||
return cmd
|
||||
}
|
||||
|
||||
func getAccount(cmd *cobra.Command, args []string) error {
|
||||
type acctCmd struct {
|
||||
storeName string
|
||||
}
|
||||
|
||||
func (a acctCmd) get(cmd *cobra.Command, args []string) error {
|
||||
if len(args) != 1 || len(args[0]) == 0 {
|
||||
return errors.New("You must provide an account name")
|
||||
}
|
||||
|
@ -40,9 +45,7 @@ func getAccount(cmd *cobra.Command, args []string) error {
|
|||
return err
|
||||
}
|
||||
key := crypto.Address(bz)
|
||||
|
||||
// TODO: make the store name a variable in getAccountCmd?
|
||||
path := "/main/key"
|
||||
path := fmt.Sprintf("/%s/key", a.storeName)
|
||||
|
||||
uri := viper.GetString(client.FlagNode)
|
||||
if uri == "" {
|
||||
|
|
Loading…
Reference in New Issue