Files
w3cjandClaude Opus 5.5 d58b24affe refactor(ui): prompts in one place: each question declares its answer
Every question is a msg.Question that declares what answers it where
devvm can't ask: AnsweredBy("--force") names a flag or command, which the
refusal names (no_input), and RefusedWith(msg.X(...)) gives a question no
flag answers its own refusal. msg.AnswerFor and its table go.

The Reporter's Ask, Confirm and Answer, and the UI's Secret, take a
Question and return a *msg.Refusal where they can't ask: with --no-input,
without a terminal, or at the end of the input, one refusal for all three
causes. Commands return it through the failure path (showFailure ->
UI.Refused: the question, then the refusal); nothing dies on an unanswered
question any more. Questions with a usual answer fall back on it instead:
network policy on, restart no, history import later, the Include line
warned, an unenforced VM stopped, the first run's size kept.

Gone: confirmed() in cli (4 callers), force_needed and no_input_terminal,
vm.Env.CanAsk and ui.CanAsk, vm's interactive, setup's terminal, the
Reporter's StdinIsTerminal/StdoutIsTerminal and the Fake's StdoutTerminal,
and every caller's terminal check (18 in vm, netpolicy, build and
sshconfig; 3 CanAsk; 1 interactive; 2 in cli). The picker's check
(CanPick) stays in the picker, which keeps its choices with --no-input
too; setup and the first run's agents and the new-VM summary still read
CanPick, because what they save or say depends on whether the picker
showed.

A Question's About context (the network policy's, a secret's howto, the
restart's changes, the size's host) is said only when it's asked.
devvm update asks before its tools change, so a refusal leaves the VM as
it is.

The CLI tests answer through a terminal (ttyin) or, explicitly, with a
test build's DEVVM_PIPED_ANSWERS=1, a line of input each.

Tests: ui's TestConfirm, TestAsk, TestAnswer, TestPromptsOnlyAtATerminal,
TestSecret, TestNoInput, TestNoTerminal, TestNoAnswer, TestPipedAnswers,
TestRefusedInterrupted, TestPickNoInput; msg's TestQuestionRefused,
TestQuestionAbout; cli's agreement test TestQuestionsDeclareAnswers (every
AnsweredBy names devvm's flags and commands, every RefusedWith a message,
no Question made otherwise) and TestCheckAnswer; vm's
TestSizeChoiceRefused; testscript prompts.txtar (each cause, a refusal of
its own, piped answers).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-05 11:49:57 -07:00

27 lines
1.1 KiB
Plaintext

# gc --caches asks for each backend before it frees anything of the
# backends' own caches, and gc asks before it deletes anything else, so
# without a terminal and without --force it refuses before deleting
# anything. The default run never touches the caches.
[darwin] mkdir $HOME/Library/Caches/lima/download/by-url-sha256/0123
[darwin] exec sh -c 'echo x > "$HOME/Library/Caches/lima/download/by-url-sha256/0123/data"'
mkdir $XDG_DATA_HOME/devvm/cache/mise/2020.1.1
exec touch -t 202001010000 $XDG_DATA_HOME/devvm/cache/mise/2020.1.1
! exec devvm gc --caches
stderr '^devvm: no_input answer=--force$'
exists $XDG_DATA_HOME/devvm/cache/mise/2020.1.1
[darwin] exists $HOME/Library/Caches/lima/download/by-url-sha256/0123/data
exec devvm gc --force
stdout '^==> deleted_mise count=1$'
[darwin] exists $HOME/Library/Caches/lima/download/by-url-sha256/0123/data
# devvm's cache/ may be deleted at any time: gc, space and images go on
# without it, and nothing makes it until it's needed.
rm $XDG_DATA_HOME/devvm/cache
exec devvm gc --force
stdout '^==> nothing_to_clean$'
exec devvm space
exec devvm images
! exists $XDG_DATA_HOME/devvm/cache