feat: flag action

This commit is contained in:
Wendell Sun
2022-02-15 23:49:41 +08:00
parent 880a802dc8
commit 14366f7030
19 changed files with 257 additions and 0 deletions

View File

@@ -65,6 +65,15 @@ func (f *StringFlag) Get(ctx *Context) string {
return ctx.String(f.Name)
}
// RunAction executes flag action if set
func (f *StringFlag) RunAction(c *Context) error {
if f.Action != nil {
return f.Action(c, c.String(f.Name))
}
return nil
}
// String looks up the value of a local StringFlag, returns
// "" if not found
func (cCtx *Context) String(name string) string {