mirror of
https://github.com/ipfs/kubo.git
synced 2025-09-19 06:42:36 +08:00
uodate json option name
License: MIT Signed-off-by: Kejie Zhang <601172892@qq.com>
This commit is contained in:
@ -27,7 +27,7 @@ type ConfigField struct {
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
configBoolOptionName = "bool"
|
configBoolOptionName = "bool"
|
||||||
configJsonOptionName = "json"
|
configJSONOptionName = "json"
|
||||||
)
|
)
|
||||||
|
|
||||||
var ConfigCmd = &cmds.Command{
|
var ConfigCmd = &cmds.Command{
|
||||||
@ -60,7 +60,7 @@ Set the value of the 'Datastore.Path' key:
|
|||||||
},
|
},
|
||||||
Options: []cmdkit.Option{
|
Options: []cmdkit.Option{
|
||||||
cmdkit.BoolOption(configBoolOptionName, "Set a boolean value."),
|
cmdkit.BoolOption(configBoolOptionName, "Set a boolean value."),
|
||||||
cmdkit.BoolOption(configJsonOptionName, "Parse stringified JSON."),
|
cmdkit.BoolOption(configJSONOptionName, "Parse stringified JSON."),
|
||||||
},
|
},
|
||||||
Run: func(req cmds.Request, res cmds.Response) {
|
Run: func(req cmds.Request, res cmds.Response) {
|
||||||
args := req.Arguments()
|
args := req.Arguments()
|
||||||
@ -92,7 +92,7 @@ Set the value of the 'Datastore.Path' key:
|
|||||||
if len(args) == 2 {
|
if len(args) == 2 {
|
||||||
value := args[1]
|
value := args[1]
|
||||||
|
|
||||||
if parseJson, _, _ := req.Option(configJsonOptionName).Bool(); parseJson {
|
if parseJSON, _, _ := req.Option(configJSONOptionName).Bool(); parseJSON {
|
||||||
var jsonVal interface{}
|
var jsonVal interface{}
|
||||||
if err := json.Unmarshal([]byte(value), &jsonVal); err != nil {
|
if err := json.Unmarshal([]byte(value), &jsonVal); err != nil {
|
||||||
err = fmt.Errorf("failed to unmarshal json. %s", err)
|
err = fmt.Errorf("failed to unmarshal json. %s", err)
|
||||||
|
Reference in New Issue
Block a user