diff --git a/cmd/ipfs/main.go b/cmd/ipfs/main.go index 17d773ab2..e50a5ca16 100644 --- a/cmd/ipfs/main.go +++ b/cmd/ipfs/main.go @@ -315,6 +315,13 @@ func callCommand(ctx context.Context, req cmds.Request, root *cmds.Command, cmd return nil, err } + if cmd.PreRun != nil { + err = cmd.PreRun(req) + if err != nil { + return nil, err + } + } + if useDaemon { cfg, err := req.Context().GetConfig() diff --git a/commands/command.go b/commands/command.go index 74beeec6e..f79bf31c0 100644 --- a/commands/command.go +++ b/commands/command.go @@ -45,6 +45,7 @@ type HelpText struct { type Command struct { Options []Option Arguments []Argument + PreRun func(req Request) error Run Function PostRun func(res Response) Marshalers map[EncodingType]Marshaler