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>
This commit is contained in:
parent
5b62109334
commit
54ac1d2fe8
|
@ -39,6 +39,7 @@
|
||||||
|
|
||||||
### Gaia CLI
|
### Gaia CLI
|
||||||
|
|
||||||
|
* [\#3841](https://github.com/cosmos/cosmos-sdk/pull/3841) Add indent to JSON of `gaiacli keys [add|show|list]`
|
||||||
* [\#3859](https://github.com/cosmos/cosmos-sdk/pull/3859) Add newline to echo of `gaiacli keys ...`
|
* [\#3859](https://github.com/cosmos/cosmos-sdk/pull/3859) Add newline to echo of `gaiacli keys ...`
|
||||||
|
|
||||||
### Gaia
|
### Gaia
|
||||||
|
|
|
@ -74,6 +74,7 @@ the flag --nosort is set.
|
||||||
cmd.Flags().Bool(flagDryRun, false, "Perform action, but don't add key to local keystore")
|
cmd.Flags().Bool(flagDryRun, false, "Perform action, but don't add key to local keystore")
|
||||||
cmd.Flags().Uint32(flagAccount, 0, "Account number for HD derivation")
|
cmd.Flags().Uint32(flagAccount, 0, "Account number for HD derivation")
|
||||||
cmd.Flags().Uint32(flagIndex, 0, "Address index number for HD derivation")
|
cmd.Flags().Uint32(flagIndex, 0, "Address index number for HD derivation")
|
||||||
|
cmd.Flags().Bool(client.FlagIndentResponse, false, "Add indent to JSON response")
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,17 +1,20 @@
|
||||||
package keys
|
package keys
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/cosmos/cosmos-sdk/client"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
func listKeysCmd() *cobra.Command {
|
func listKeysCmd() *cobra.Command {
|
||||||
return &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "list",
|
Use: "list",
|
||||||
Short: "List all keys",
|
Short: "List all keys",
|
||||||
Long: `Return a list of all public keys stored by this key manager
|
Long: `Return a list of all public keys stored by this key manager
|
||||||
along with their associated name and address.`,
|
along with their associated name and address.`,
|
||||||
RunE: runListCmd,
|
RunE: runListCmd,
|
||||||
}
|
}
|
||||||
|
cmd.Flags().Bool(client.FlagIndentResponse, false, "Add indent to JSON response")
|
||||||
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
func runListCmd(cmd *cobra.Command, args []string) error {
|
func runListCmd(cmd *cobra.Command, args []string) error {
|
||||||
|
|
|
@ -3,6 +3,7 @@ package keys
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/cosmos/cosmos-sdk/client"
|
||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/crypto"
|
"github.com/cosmos/cosmos-sdk/crypto"
|
||||||
"github.com/cosmos/cosmos-sdk/crypto/keys"
|
"github.com/cosmos/cosmos-sdk/crypto/keys"
|
||||||
|
@ -49,6 +50,7 @@ consisting of all the keys provided by name and multisig threshold.`,
|
||||||
cmd.Flags().BoolP(FlagDevice, "d", false, "Output the address in the device")
|
cmd.Flags().BoolP(FlagDevice, "d", false, "Output the address in the device")
|
||||||
cmd.Flags().Uint(flagMultiSigThreshold, 1, "K out of N required signatures")
|
cmd.Flags().Uint(flagMultiSigThreshold, 1, "K out of N required signatures")
|
||||||
cmd.Flags().BoolP(flagShowMultiSig, "m", false, "Output multisig pubkey constituents, threshold, and weights")
|
cmd.Flags().BoolP(flagShowMultiSig, "m", false, "Output multisig pubkey constituents, threshold, and weights")
|
||||||
|
cmd.Flags().Bool(client.FlagIndentResponse, false, "Add indent to JSON response")
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
|
@ -119,7 +119,13 @@ func printKeyInfo(keyInfo keys.Info, bechKeyOut bechKeyOutFn) {
|
||||||
printKeyOutput(ko)
|
printKeyOutput(ko)
|
||||||
|
|
||||||
case OutputFormatJSON:
|
case OutputFormatJSON:
|
||||||
out, err := MarshalJSON(ko)
|
var out []byte
|
||||||
|
var err error
|
||||||
|
if viper.GetBool(client.FlagIndentResponse) {
|
||||||
|
out, err = cdc.MarshalJSONIndent(ko, "", " ")
|
||||||
|
} else {
|
||||||
|
out, err = cdc.MarshalJSON(ko)
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
@ -142,11 +148,18 @@ func printInfos(infos []keys.Info) {
|
||||||
}
|
}
|
||||||
|
|
||||||
case OutputFormatJSON:
|
case OutputFormatJSON:
|
||||||
out, err := MarshalJSON(kos)
|
var out []byte
|
||||||
|
var err error
|
||||||
|
|
||||||
|
if viper.GetBool(client.FlagIndentResponse) {
|
||||||
|
out, err = cdc.MarshalJSONIndent(kos, "", " ")
|
||||||
|
} else {
|
||||||
|
out, err = cdc.MarshalJSON(kos)
|
||||||
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println(string(out))
|
fmt.Println(string(out))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue