Skip to main content

needs_terminal

Function needs_terminal 

Source
pub fn needs_terminal(line: &str) -> bool
Expand description

Compose a PATH for the spawned process that always includes the directory containing the program — where node, npm, and friends usually live in an nvm install. The user’s existing PATH stays as a fallback after our prepended directory. A Command that never opens a console window on Windows.

A GUI host (a Tauri app, an IDE) spawning a console-subsystem CLI gets a black console flashed on screen for every agent run and every --version probe. CREATE_NO_WINDOW suppresses it. Use this in place of Command::new for anything a desktop app spawns; it is a plain Command::new on every other platform, so call sites stay cfg-free. Whether a line from a child suggests it wanted a terminal and did not get one.

Every child spawned here gets pipes, never a TTY, so isatty is false and a CLI may change what it prints or refuse to run. Most of the time that is welcome — no colour codes, no progress bars — but a CLI built around interactive prompts fails, and the message it gives is easy to miss among ordinary stderr.

Recognising it turns a confusing exit into a next step: run the CLI in whatever non-interactive mode it has (--yes, -p, exec, …).