argValue returns the value of the nth argument.
(n int)
| 83 | |
| 84 | // argValue returns the value of the nth argument. |
| 85 | func (c commandInfo) argValue(n int) (string, error) { |
| 86 | if c.cmd == nil { |
| 87 | return "", fmt.Errorf("%w: arg: cmd is nil", ErrHookTemplateParse) |
| 88 | } |
| 89 | flags := c.cmd.Flags() |
| 90 | v := flags.Arg(n) |
| 91 | if v == "" && n >= flags.NArg() { |
| 92 | return "", fmt.Errorf("%w: arg: %dth argument not set", ErrHookTemplateParse, n) |
| 93 | } |
| 94 | return v, nil |
| 95 | } |