| 496 | } |
| 497 | |
| 498 | func shouldRunCompletion(cmd *Command) bool { |
| 499 | tracef("checking completions on command %[1]q", cmd.Name) |
| 500 | |
| 501 | if !cmd.Root().shellCompletion { |
| 502 | tracef("completion not enabled skipping %[1]q", cmd.Name) |
| 503 | return false |
| 504 | } |
| 505 | |
| 506 | if argsArguments := cmd.Args(); argsArguments.Present() { |
| 507 | name := argsArguments.First() |
| 508 | if cmd := cmd.Command(name); cmd != nil { |
| 509 | // let the command handle the completion |
| 510 | return false |
| 511 | } |
| 512 | } |
| 513 | |
| 514 | tracef("no subcommand found for completion %[1]q", cmd.Name) |
| 515 | return true |
| 516 | } |
| 517 | |
| 518 | func runCompletion(ctx context.Context, cmd *Command) { |
| 519 | if cmd.ShellComplete != nil { |