mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-21 10:27:46 +08:00
commands: Added PreRun function to command
This commit is contained in:
parent
1281b25105
commit
856d2896a7
@ -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()
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user