completeSystemCommands autocompleta comandos do sistema
(prefix string)
| 530 | |
| 531 | // completeSystemCommands autocompleta comandos do sistema |
| 532 | func (cli *ChatCLI) completeSystemCommands(prefix string) []string { |
| 533 | var completions []string |
| 534 | |
| 535 | // Obter o PATH do sistema |
| 536 | pathEnv := os.Getenv("PATH") |
| 537 | paths := strings.Split(pathEnv, string(os.PathListSeparator)) |
| 538 | |
| 539 | seen := make(map[string]bool) |
| 540 | |
| 541 | for _, pathDir := range paths { |
| 542 | files, err := os.ReadDir(pathDir) |
| 543 | if err != nil { |
| 544 | continue |
| 545 | } |
| 546 | |
| 547 | for _, file := range files { |
| 548 | name := file.Name() |
| 549 | if strings.HasPrefix(name, prefix) && !seen[name] { |
| 550 | seen[name] = true |
| 551 | completions = append(completions, name) |
| 552 | } |
| 553 | } |
| 554 | } |
| 555 | |
| 556 | return completions |
| 557 | } |
| 558 | |
| 559 | // getContextSuggestions - Sugestões melhoradas para /context |
| 560 | // contextSubcommands is the static list of `/context <sub>` verbs. |
no test coverage detected