(t *testing.T)
| 194 | } |
| 195 | |
| 196 | func Test_Help_Custom_Flags(t *testing.T) { |
| 197 | oldFlag := HelpFlag |
| 198 | defer func() { |
| 199 | HelpFlag = oldFlag |
| 200 | }() |
| 201 | |
| 202 | HelpFlag = &BoolFlag{ |
| 203 | Name: "help", |
| 204 | Aliases: []string{"x"}, |
| 205 | Usage: "show help", |
| 206 | } |
| 207 | |
| 208 | out := &bytes.Buffer{} |
| 209 | |
| 210 | cmd := &Command{ |
| 211 | Flags: []Flag{ |
| 212 | &BoolFlag{Name: "foo", Aliases: []string{"h"}}, |
| 213 | }, |
| 214 | Action: func(_ context.Context, cmd *Command) error { |
| 215 | assert.True(t, cmd.Bool("h"), "custom help flag not set") |
| 216 | return nil |
| 217 | }, |
| 218 | Writer: out, |
| 219 | } |
| 220 | |
| 221 | _ = cmd.Run(buildTestContext(t), []string{"test", "-h"}) |
| 222 | require.Len(t, out.String(), 0) |
| 223 | } |
| 224 | |
| 225 | func Test_Help_Nil_Flags(t *testing.T) { |
| 226 | oldFlag := HelpFlag |
nothing calls this directly
no test coverage detected