Skip to content

v0.x: accessible prompts skip hidden pages, and running out of answers fails

This changes what --accessible (or GTB_ACCESSIBLE=true) does with a piped stdin. A terminal user sees no difference. It retires the limit described in Props.IO, and the setup wizards' test seams.

What changed

  • Hidden pages are skipped. huh's accessible mode asks every page in turn, including the ones an earlier answer hides (huh v2.0.3). The framework's wizards (init ai, the forge credential and SSH wizards) and the gtb generator's (generate project, generate command, gtb wizard) now run each visible page on its own, so an answers script covers only the pages a person would see. Asking a hidden page with no options used to panic.
  • Each page is built when it is asked. Accessible mode never refreshes a page's computed text, so a label or summary built before the earlier answers showed stale values. The project wizard's summary is now current.
  • Answers that run out fail. When stdin ends before every question is answered, setup.RunForm returns setup.ErrInputEnded. huh used to take each remaining question's default without validating it, and the form reported success. A last answer without a trailing newline still counts.
  • Enter keeps a pre-filled answer. huh validated an empty line as "", so a required field refused its own pre-filled value. A gtb wizard revisit stalled on the repository until it was retyped.
  • Several forms in turn can share one pipe. Each form used to wrap stdin in a buffered reader, which kept the next form's answers.

Migration

  • A script that pipes answers gives one line per question it is asked; an empty line takes that question's default. Drop any answers that were there only for hidden pages: they are now read by the next question.
  • A caller that runs its own form through setup.RunForm and needs to tell this apart from other failures checks errors.Is(err, setup.ErrInputEnded).
  • A tool's own wizard with hidden groups still has huh's behaviour, since the page runner is internal to the framework. Until huh releases the fixes proposed in huh#780, huh#832 and huh#833, keep its hidden pages out of accessible runs yourself.