@cryptotaxi247 / kubo / commits / c9ff778bd

Added -bool option to ipfs config command

Mildred Ki'Lya committed Jan 30, 2015 at 10:37 UTC c9ff778bd644988c908874190960a3cfa9c9c954
1 file changed +9 -2
core/commands/config.go
+9 -2
@@ -57,6 +57,9 @@ Set the value of the 'datastore.path' key:
57 cmds.StringArg("key", true, false, "The key of the config entry (e.g. \"Addresses.API\")"),
58 cmds.StringArg("value", false, false, "The value to set the config entry to"),
59 },
60 + Options: []cmds.Option{
61 + cmds.BoolOption("bool", "Set a boolean value"),
62 + },
63 Run: func(req cmds.Request, res cmds.Response) {
64 args := req.Arguments()
65 key := args[0]
@@ -72,7 +75,11 @@ Set the value of the 'datastore.path' key:
75 var output *ConfigField
76 if len(args) == 2 {
77 value := args[1]
75 - output, err = setConfig(r, key, value)
78 + if isbool, _, _ := req.Option("bool").Bool(); isbool {
79 + output, err = setConfig(r, key, value == "true")
80 + } else {
81 + output, err = setConfig(r, key, value)
82 + }
83 } else {
84 output, err = getConfig(r, key)
85 }
@@ -208,7 +215,7 @@ func getConfig(r repo.Repo, key string) (*ConfigField, error) {
215 }, nil
216 }
217
211 -func setConfig(r repo.Repo, key, value string) (*ConfigField, error) {
218 +func setConfig(r repo.Repo, key string, value interface{}) (*ConfigField, error) {
219 err := r.SetConfigKey(key, value)
220 if err != nil {
221 return nil, fmt.Errorf("Failed to set config value: %s", err)