32 lines
646 B
Go
32 lines
646 B
Go
package keys
|
|
|
|
import (
|
|
"github.com/cosmos/cosmos-sdk/client/flags"
|
|
"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(flags.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
|
|
}
|