userSetOption returns true if the option was set by the user. This is helpful if the zero value of a flag is meaningful, and you need to distinguish between the user setting the flag to the zero value and the user not setting the flag at all.
(inv *serpent.Invocation, flagName string)
| 25 | // to distinguish between the user setting the flag to the zero value and |
| 26 | // the user not setting the flag at all. |
| 27 | func userSetOption(inv *serpent.Invocation, flagName string) bool { |
| 28 | for _, opt := range inv.Command.Options { |
| 29 | if opt.Name == flagName { |
| 30 | return !(opt.ValueSource == serpent.ValueSourceNone || opt.ValueSource == serpent.ValueSourceDefault) |
| 31 | } |
| 32 | } |
| 33 | return false |
| 34 | } |
| 35 | |
| 36 | // durationDisplay formats a duration for easier display: |
| 37 | // - Durations of 24 hours or greater are displays as Xd |
no outgoing calls
no test coverage detected