commands: Added PreRun function to command

This commit is contained in:
Matt Bell 2015-01-21 15:18:45 -08:00
parent 1281b25105
commit 856d2896a7
2 changed files with 8 additions and 0 deletions

View File

@ -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()

View File

@ -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