@cryptotaxi247 / kubo / commits / 856d2896a

commands: Added PreRun function to command

Matt Bell committed Jan 21, 2015 at 15:18 UTC 856d2896a7dce5d509f8438b81677a218a8125bb
2 files changed +8
cmd/ipfs/main.go
+7
@@ -315,6 +315,13 @@ func callCommand(ctx context.Context, req cmds.Request, root *cmds.Command, cmd
315 return nil, err
316 }
317
318 + if cmd.PreRun != nil {
319 + err = cmd.PreRun(req)
320 + if err != nil {
321 + return nil, err
322 + }
323 + }
324 +
325 if useDaemon {
326
327 cfg, err := req.Context().GetConfig()
commands/command.go
+1
@@ -45,6 +45,7 @@ type HelpText struct {
45 type Command struct {
46 Options []Option
47 Arguments []Argument
48 + PreRun func(req Request) error
49 Run Function
50 PostRun func(res Response)
51 Marshalers map[EncodingType]Marshaler