2018-02-22 07:17:19 -08:00
|
|
|
package keys
|
|
|
|
|
2018-02-28 23:16:54 -08:00
|
|
|
import (
|
|
|
|
"github.com/spf13/cobra"
|
2019-04-04 07:36:39 -07:00
|
|
|
|
|
|
|
"github.com/cosmos/cosmos-sdk/client"
|
2018-02-28 23:16:54 -08:00
|
|
|
)
|
|
|
|
|
2019-02-08 12:45:23 -08:00
|
|
|
func listKeysCmd() *cobra.Command {
|
2019-03-13 10:36:52 -07:00
|
|
|
cmd := &cobra.Command{
|
2019-02-08 12:45:23 -08:00
|
|
|
Use: "list",
|
|
|
|
Short: "List all keys",
|
|
|
|
Long: `Return a list of all public keys stored by this key manager
|
2018-02-22 07:17:19 -08:00
|
|
|
along with their associated name and address.`,
|
2019-02-08 12:45:23 -08:00
|
|
|
RunE: runListCmd,
|
|
|
|
}
|
2019-03-13 10:36:52 -07:00
|
|
|
cmd.Flags().Bool(client.FlagIndentResponse, false, "Add indent to JSON response")
|
|
|
|
return cmd
|
2018-02-22 07:17:19 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
func runListCmd(cmd *cobra.Command, args []string) error {
|
2019-02-06 11:23:49 -08:00
|
|
|
kb, err := NewKeyBaseFromHomeFlag()
|
2018-02-22 07:17:19 -08:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
infos, err := kb.List()
|
|
|
|
if err == nil {
|
|
|
|
printInfos(infos)
|
|
|
|
}
|
|
|
|
return err
|
|
|
|
}
|