Duration returns the value of a duration flag by name Returns 0 if flag doesn't exist or isn't a DurationFlag
(name string)
| 86 | // Duration returns the value of a duration flag by name |
| 87 | // Returns 0 if flag doesn't exist or isn't a DurationFlag |
| 88 | func (c *Command) Duration(name string) time.Duration { |
| 89 | if flag, ok := c.flagMap[name]; ok { |
| 90 | if sf, ok := flag.(*DurationFlag); ok { |
| 91 | return sf.Value() |
| 92 | } |
| 93 | } |
| 94 | return time.Duration(0) |
| 95 | } |
| 96 | |
| 97 | // RequireDuration returns the value of a duration flag by name |
| 98 | // Panics if flag doesn't exist or isn't a DurationFlag |