Allow CLI commands to run without a TTY#5854
Conversation
`viam module generate` and fragment removal use charmbracelet/huh forms and spinners that require a terminal. This makes them unusable from CI, scripts, or tools like Claude Code even when all flags are provided. Detect non-interactive environments via os.Stdin and: - Return clear errors when interactive input would be needed (missing flags, unauthenticated) - Replace the huh spinner with plain status line output - Leave all interactive (TTY) behavior unchanged
f947db1 to
6200142
Compare
…generate-tty # Conflicts: # cli/module_generate.go
| // logTitle updates the spinner in interactive mode, prints a status line | ||
| // in non-interactive mode, and is a no-op in debug mode. |
There was a problem hiding this comment.
I'm a little confused, why do we want this to be a no-op in debug mode? I would think that debug mode should have no impact on behavior other than providing additional log messages, at least when we're in interactive mode.
| if globalArgs.Debug { | ||
| action() | ||
| } else { | ||
| if interactive && !globalArgs.Debug { |
There was a problem hiding this comment.
SImilar question here, why do treat the debug case and the non-interactive case the same?
|
Hey @ashitaka1 — this PR has been approved and CI has been green for 3+ business days. Ready to merge? Auto-comment from overwatch. Will not re-nudge for 7 days. |
|
Hey @ashitaka1 — this PR has been approved and CI has been green for 8+ business days. Ready to merge? Auto-comment from overwatch. Will not re-nudge for 7 days. |
|
Hey @ashitaka1 — this PR has been approved and CI has been green for 13+ business days. Ready to merge? Auto-comment from overwatch. Will not re-nudge for 7 days. |
|
Hey @ashitaka1 — this PR has been approved and CI has been green for 18+ business days. Ready to merge? Auto-comment from overwatch. Will not re-nudge for 7 days. |
Summary
viam module generateand fragment removal usecharmbracelet/huhforms and spinners that require a terminal, making them unusable from CI, scripts, or automation tools even when all flags are providedisInteractive()check (viaos.Stdinfd) and returns clear errors when interactive input would be needed (missing flags, unauthenticated)Test plan
viam module generate --name foowithout TTY → clear "missing required flags" errorviam module generateunauthenticated without TTY → clear "authentication required" errorviam module generatewith all flags, authenticated, without TTY → runs successfully with status line output🤖 Generated with Claude Code