runToolMenu remains as a fallback used by tests that exercise the non-TTY rendering path of the legacy single-step menu. It is no longer wired into the launch command, but kept to avoid breaking the existing test that asserts on its output.
(out io.Writer, items []string)
| 285 | // longer wired into the launch command, but kept to avoid breaking |
| 286 | // the existing test that asserts on its output. |
| 287 | func runToolMenu(out io.Writer, items []string) (string, error) { |
| 288 | model := newToolMenuModel(items) |
| 289 | file, ok := out.(*os.File) |
| 290 | if !ok || !isTerminal(file) { |
| 291 | _, err := fmt.Fprint(out, model.View()) |
| 292 | return "", err |
| 293 | } |
| 294 | program := tea.NewProgram(model, tea.WithOutput(out)) |
| 295 | finalModel, err := program.Run() |
| 296 | if err != nil { |
| 297 | return "", err |
| 298 | } |
| 299 | if menu, ok := finalModel.(toolMenuModel); ok { |
| 300 | return menu.selected, nil |
| 301 | } |
| 302 | return "", nil |
| 303 | } |
| 304 | |
| 305 | func isTerminal(file *os.File) bool { |
| 306 | info, err := file.Stat() |
nothing calls this directly
no test coverage detected