flagValue returns the value that was set for the given flag when the hook was invoked.
(flagName string)
| 71 | |
| 72 | // flagValue returns the value that was set for the given flag when the hook was invoked. |
| 73 | func (c commandInfo) flagValue(flagName string) (string, error) { |
| 74 | if c.cmd == nil { |
| 75 | return "", fmt.Errorf("%w: flagValue: cmd is nil", ErrHookTemplateParse) |
| 76 | } |
| 77 | f := c.cmd.Flag(flagName) |
| 78 | if f == nil { |
| 79 | return "", fmt.Errorf("%w: flagValue: no flags found", ErrHookTemplateParse) |
| 80 | } |
| 81 | return f.Value.String(), nil |
| 82 | } |
| 83 | |
| 84 | // argValue returns the value of the nth argument. |
| 85 | func (c commandInfo) argValue(n int) (string, error) { |