mirror of
https://github.com/devvmhq/devvm.git
synced 2026-12-01 16:27:33 -10:00
A global --no-input (persistent on the root, with --help and -v): no question is asked or read. The ui's prompts (Ask, Confirm, Answer, Secret, Pick/PickOne in a terminal) show the question, then fail with no_input naming what answers it (msg.AnswerFor, by the question's ID), or no_input_terminal for a question only a terminal answers. ui.Flags and SetFlags carry -v and --no-input. Answers: --network-policy/--no-network-policy, --here, devvm size -g, devvm setup --features/--backend, devvm network -g, devvm ssh-agent add, devvm restart, --ssh-config (new, on devvm, host and code: the Include line without asking; sshconfig.Config.AddInclude, vm.Env.AddInclude), --stdin, and --force. --force (-f) only skips a confirmation, and destructive commands need it without a terminal (force_needed, a failure, not a usage error): rm (new rm_confirm), gc (it went ahead without a terminal), gc --caches (now allowed without a terminal with --force), images rm (images_rm_confirm), secret rm (secret_rm_confirm), adopt (adopt_vm), rebuild when images are built on the one rebuilt (build.Env.Force). rm --no-export skips the export; rm's parent-folder, earlier-folder and --clone confirmations are terminal-only and --force never answers them (vm.RmOptions). gc --tools --force splits: --recent (only with --tools, gc_recent_needs_tools) drops the hour's hold and keeps the refusal while a VM is being made (gc_recent_making); gc_tools_recent names devvm gc --tools --recent. gc_caches_need_terminal goes. Tests: TestNoInput, TestAnswers, TestConfirmed, TestRmConfirms, TestAdopt (--force), TestRebuild (force_needed, then Force); secret, rebuild, images, gc*, clone, subfolder, existing scripts. e2e: rm/gc/images rm/secret rm/rebuild with --force (and --no-export where rm -f skipped the export), and the clone section's rm with its checks. Docs: commands.md (Questions devvm asks, rm, flags), first-vm, clone, images (cleaning up, --recent), space, coding-agents, internals overview and images; CLI reference. Co-Authored-By: Claude Opus 5.5 <[email protected]>
113 lines
3.5 KiB
Plaintext
113 lines
3.5 KiB
Plaintext
# setup: the default backend, base's features, and new VMs' size and
|
|
# network policy (all asked in a terminal, which Go tests cover; without
|
|
# one, the backend, size and network policy aren't asked and the features
|
|
# are kept, or every one until they're chosen; --backend and --features
|
|
# without asking). A new choice of features says base rebuilds, and once
|
|
# images are built that devvm gc deletes the old ones.
|
|
env DEVVM_MESSAGES=names
|
|
env CHOSEN=$XDG_CONFIG_HOME/devvm/base-features
|
|
|
|
# Kept: none chosen; no backend or size asked.
|
|
exec devvm setup
|
|
stdout '^==> base_features_none$'
|
|
! stdout base_will_rebuild
|
|
! stdout default_backend
|
|
! stdout 'size_question|size_defaults'
|
|
! exists $XDG_CONFIG_HOME/devvm/backend
|
|
! exists $XDG_CONFIG_HOME/devvm/size
|
|
! stderr .
|
|
! stub_calls
|
|
|
|
# Unchosen: every feature.
|
|
rm $CHOSEN
|
|
exec devvm setup
|
|
stdout '^==> base_features features=cli-tools fzf omb$'
|
|
! stdout base_will_rebuild
|
|
|
|
# --features, in the order features run; nothing built yet.
|
|
exec devvm setup --features omb,fzf
|
|
stdout '^==> base_features features=fzf omb$'
|
|
stdout '^==> base_will_rebuild$'
|
|
! stdout gc_old_hint
|
|
! stdout default_backend
|
|
cmp $CHOSEN fzf-omb
|
|
exec devvm setup --features fzf,omb
|
|
! stdout base_will_rebuild
|
|
|
|
# Built: a new choice rebuilds base, and gc deletes the old one.
|
|
exec devvm build base
|
|
exec devvm setup --features none
|
|
stdout '^==> base_features_none$'
|
|
stdout '^==> base_will_rebuild$'
|
|
stdout '^gc_old_hint$'
|
|
exec devvm build base
|
|
stdout '^==> building_image image=base key='
|
|
exec devvm gc --force
|
|
stdout '^gc_image image=base key='
|
|
|
|
# A name that isn't a feature changes nothing.
|
|
! exec devvm setup --features fzf,nope
|
|
stderr '^devvm: no_feature feature=nope features=cli-tools desktop fzf omb$'
|
|
! stdout base_features
|
|
exec devvm setup
|
|
stdout '^==> base_features_none$'
|
|
|
|
# The default backend: only it, unless --features is given too.
|
|
exec devvm setup --backend lima
|
|
stdout '^==> default_backend backend=lima$'
|
|
! stdout base_features
|
|
cmp $XDG_CONFIG_HOME/devvm/backend lima.txt
|
|
exec devvm setup --backend lima --features fzf
|
|
stdout '^==> default_backend backend=lima$'
|
|
stdout '^==> base_features features=fzf$'
|
|
! exec devvm setup --backend nope
|
|
stderr '^devvm: backend_unknown backends=docker, lima, smolvm name=nope$'
|
|
cmp $XDG_CONFIG_HOME/devvm/backend lima.txt
|
|
|
|
# New VMs' size is devvm size -g's, and without a terminal nothing asks
|
|
# for it or for new VMs' network policy. Flags for a new VM are devvm
|
|
# [IMAGE]'s alone, so setup doesn't take them.
|
|
! exec devvm setup --cpus 2
|
|
stderr '^devvm: flag_unknown command=devvm setup flag=--cpus$'
|
|
! exec devvm setup --memory 8
|
|
stderr '^devvm: flag_unknown command=devvm setup flag=--memory$'
|
|
! exists $XDG_CONFIG_HOME/devvm/size
|
|
! exists $XDG_CONFIG_HOME/devvm/network
|
|
|
|
# --features none chooses none; --features '' is refused, and changes
|
|
# nothing.
|
|
exec devvm setup --features fzf
|
|
! exec devvm setup --features ''
|
|
stderr '^devvm: flag_blank flag=features$'
|
|
cmp $CHOSEN fzf.txt
|
|
exec devvm setup --features none
|
|
stdout '^==> base_features_none$'
|
|
exec cat $CHOSEN
|
|
! stdout .
|
|
|
|
# The network policy saved for new VMs: off makes one without it.
|
|
exec sh -c 'echo off > "$XDG_CONFIG_HOME/devvm/network"'
|
|
mkdir $WORK/off
|
|
cd $WORK/off
|
|
exec git init -q
|
|
exec devvm --no-git-protect base
|
|
exec sh -c 'cat "$XDG_DATA_HOME"/devvm/vms/devvm-off-*'
|
|
stdout '^net=off$'
|
|
cd $WORK
|
|
|
|
# An unreadable choice stays for you to fix.
|
|
cp bad $CHOSEN
|
|
! exec devvm setup
|
|
stderr '^devvm: setup_failed reason=.*base-features'
|
|
cmp $CHOSEN bad
|
|
|
|
-- fzf-omb --
|
|
fzf
|
|
omb
|
|
-- lima.txt --
|
|
lima
|
|
-- fzf.txt --
|
|
fzf
|
|
-- bad --
|
|
Not_A_Feature
|