cosmos-sdk/client/keys/list.go
Frank Yang 54ac1d2fe8 Merge PR #3841: Add indent to JSON of gaiacli key [add|show|list]
* Add indent to JSON of `gaiacli key list`

* Add `-o json --indent` to `keys [add|show|list]`

* Add change log.

* Move entry from CHANGELOG.md to PENDING.md

* Update PENDING.md

Add indent to JSON of `gaiacli key [add|show|list]`

Co-Authored-By: yangyanqing <yangyanqing.cn@gmail.com>
2019-03-13 10:36:52 -07:00

32 lines
641 B
Go

package keys
import (
"github.com/cosmos/cosmos-sdk/client"
"github.com/spf13/cobra"
)
func listKeysCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "list",
Short: "List all keys",
Long: `Return a list of all public keys stored by this key manager
along with their associated name and address.`,
RunE: runListCmd,
}
cmd.Flags().Bool(client.FlagIndentResponse, false, "Add indent to JSON response")
return cmd
}
func runListCmd(cmd *cobra.Command, args []string) error {
kb, err := NewKeyBaseFromHomeFlag()
if err != nil {
return err
}
infos, err := kb.List()
if err == nil {
printInfos(infos)
}
return err
}