MCPcopy
hub / github.com/urfave/cli / TestDefaultCompleteWithFlags

Function TestDefaultCompleteWithFlags

help_test.go:1294–1485  ·  help_test.go::TestDefaultCompleteWithFlags
(t *testing.T)

Source from the content-addressed store, hash-verified

1292}
1293
1294func TestDefaultCompleteWithFlags(t *testing.T) {
1295 origArgv := os.Args
1296 t.Cleanup(func() { os.Args = origArgv })
1297
1298 for _, tc := range []struct {
1299 name string
1300 cmd *Command
1301 argv []string
1302 env map[string]string
1303 expected string
1304 }{
1305 {
1306 name: "empty",
1307 cmd: &Command{},
1308 argv: []string{"prog", "cmd"},
1309 env: map[string]string{"SHELL": "bash"},
1310 expected: "",
1311 },
1312 {
1313 name: "typical-flag-suggestion",
1314 cmd: &Command{
1315 Flags: []Flag{
1316 &BoolFlag{Name: "excitement"},
1317 &StringFlag{Name: "hat-shape"},
1318 },
1319 parent: &Command{
1320 Name: "cmd",
1321 Flags: []Flag{
1322 &BoolFlag{Name: "happiness"},
1323 &Int64Flag{Name: "everybody-jump-on"},
1324 },
1325 Commands: []*Command{
1326 {Name: "putz"},
1327 },
1328 },
1329 },
1330 argv: []string{"cmd", "--e", completionFlag},
1331 env: map[string]string{"SHELL": "bash"},
1332 expected: "--excitement\n",
1333 },
1334 {
1335 name: "typical-flag-suggestion-hidden-bool",
1336 cmd: &Command{
1337 Flags: []Flag{
1338 &BoolFlag{Name: "excitement", Hidden: true},
1339 &StringFlag{Name: "hat-shape"},
1340 },
1341 parent: &Command{
1342 Name: "cmd",
1343 Flags: []Flag{
1344 &BoolFlag{Name: "happiness"},
1345 &Int64Flag{Name: "everybody-jump-on"},
1346 },
1347 Commands: []*Command{
1348 {Name: "putz"},
1349 },
1350 },
1351 },

Callers

nothing calls this directly

Calls 4

buildTestContextFunction · 0.85
RootMethod · 0.80
RunMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected