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
|
||||
|
||||
* [\#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 ...`
|
||||
|
||||
### 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().Uint32(flagAccount, 0, "Account 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
|
||||
}
|
||||
|
||||
|
|
|
@ -1,17 +1,20 @@
|
|||
package keys
|
||||
|
||||
import (
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func listKeysCmd() *cobra.Command {
|
||||
return &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 {
|
||||
|
|
|
@ -3,6 +3,7 @@ package keys
|
|||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/crypto"
|
||||
"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().Uint(flagMultiSigThreshold, 1, "K out of N required signatures")
|
||||
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
|
||||
}
|
||||
|
|
|
@ -119,7 +119,13 @@ func printKeyInfo(keyInfo keys.Info, bechKeyOut bechKeyOutFn) {
|
|||
printKeyOutput(ko)
|
||||
|
||||
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 {
|
||||
panic(err)
|
||||
}
|
||||
|
@ -142,11 +148,18 @@ func printInfos(infos []keys.Info) {
|
|||
}
|
||||
|
||||
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 {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
fmt.Println(string(out))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue