(t *testing.T)
| 137 | } |
| 138 | |
| 139 | func Test_HelpCommand_RequiredFlagsNoDefault(t *testing.T) { |
| 140 | output := new(bytes.Buffer) |
| 141 | |
| 142 | cmd := &Command{ |
| 143 | Flags: []Flag{ |
| 144 | &Int64Flag{Name: "foo", Aliases: []string{"f"}, Required: true}, |
| 145 | }, |
| 146 | Arguments: AnyArguments, |
| 147 | Writer: output, |
| 148 | } |
| 149 | |
| 150 | _ = cmd.Run(buildTestContext(t), []string{"test", "help"}) |
| 151 | |
| 152 | expected := `NAME: |
| 153 | test - A new cli application |
| 154 | |
| 155 | USAGE: |
| 156 | test [global options] [arguments...] |
| 157 | |
| 158 | GLOBAL OPTIONS: |
| 159 | --foo int, -f int |
| 160 | --help, -h show help |
| 161 | ` |
| 162 | |
| 163 | assert.Contains(t, output.String(), expected, |
| 164 | "expected output to include usage text") |
| 165 | } |
| 166 | |
| 167 | // Test_HelpCommand_ParsesFlags is a regression test for #2271: flags |
| 168 | // declared on a user-supplied command named "help" must still be parsed. |
nothing calls this directly
no test coverage detected