@cryptotaxi247 / kubo / commits / 7f8079372

refact(cmd/patch): change string to const

License: MIT Signed-off-by: chenminjian <727180553@qq.com>

chenminjian committed Jan 19, 2019 at 16:52 UTC 7f80793722ee446565ec3328b312b49ad93893a3
1 file changed +6 -2
core/commands/object/patch.go
+6 -2
@@ -167,6 +167,10 @@ Remove a Merkle-link from the given object and return the hash of the result.
167 },
168 }
169
170 +const (
171 + createOptionName = "create"
172 +)
173 +
174 var patchAddLinkCmd = &cmds.Command{
175 Helptext: cmdkit.HelpText{
176 Tagline: "Add a link to a given object.",
@@ -189,7 +193,7 @@ to a file containing 'bar', and returns the hash of the new object.
193 cmdkit.StringArg("ref", true, false, "IPFS object to add link to."),
194 },
195 Options: []cmdkit.Option{
192 - cmdkit.BoolOption("create", "p", "Create intermediary nodes."),
196 + cmdkit.BoolOption(createOptionName, "p", "Create intermediary nodes."),
197 },
198 Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error {
199 api, err := cmdenv.GetApi(env, req)
@@ -209,7 +213,7 @@ to a file containing 'bar', and returns the hash of the new object.
213 return err
214 }
215
212 - create, _ := req.Options["create"].(bool)
216 + create, _ := req.Options[createOptionName].(bool)
217 if err != nil {
218 return err
219 }