mirror of
https://github.com/devvmhq/devvm.git
synced 2026-12-01 16:27:33 -10:00
devvm [IMAGE]'s flags for a new VM (--backend, --from, --cpus, --memory, --disk, --ports, --network-policy, --no-network-policy) are the root's own, so devvm ls --cpus 4 and devvm setup --cpus 2 fail as unknown flags. build, rebuild and images rm take --backend and --from; images, gc and space take --backend as a filter of their own (images and space now filter: only that backend's rows); doctor takes --backend; restart and tools take none. ports -g is local on ports, ports add and ports rm. No command has a persistent flag. One name, one meaning: network log --follow loses -f (-f is --force's, and gc --force gains it); the hidden secret get's --force becomes --to-terminal. Flag defaults name the setting command (devvm size -g, devvm ports -g, devvm setup --backend); descriptions lose then/also openings. Special values are words: an empty flag value (flag_blank) or an empty argument (arg_blank) is refused everywhere, replacing features_empty. Durations: state.ParseDuration (a whole number and m, h, d or w) for gc --older-than, retention's ages and ssh-agent add --lifetime (which also takes forever, via sshagent.CheckLifetime), with one message, bad_duration, replacing gc_bad_age and agent_lifetime_invalid. Blanks are checked with the other usage errors (checkCommand, before checkFlags), and an unknown --backend NAME is a usage error checked first too (checkFlagValue, against registry.Names, which a test keeps equal to the registry's own). Tests: TestPersistentFlags, TestFlagNamesHaveOneMeaning, TestUpFlagsAreUpsAlone, TestParseDuration, TestCheckLifetime; root, setup, images, space, gc_history, retention, ssh_agent and network_log scripts. Docs: commands.md (Flags and values), from.md, install.md, images.md, space.md, settings.md, ssh.md, network pages; CLI reference. Co-Authored-By: Claude Opus 5.5 <[email protected]>
68 lines
2.1 KiB
Plaintext
68 lines
2.1 KiB
Plaintext
# devvm --help prints usage.
|
|
exec devvm --help
|
|
stdout '^Usage:'
|
|
stdout 'devvm \[IMAGE\] \[flags\]'
|
|
! stderr .
|
|
cp stdout help.txt
|
|
|
|
# So do devvm help and -h; devvm help COMMAND prints the command's.
|
|
exec devvm help
|
|
cmp stdout help.txt
|
|
exec devvm -h
|
|
cmp stdout help.txt
|
|
exec devvm help build
|
|
stdout 'devvm build IMAGE \[flags\]'
|
|
exec devvm build --help
|
|
stdout 'devvm build IMAGE \[flags\]'
|
|
! stub_calls
|
|
|
|
# An unknown flag is a usage error: its message on stderr, then the line
|
|
# naming the command's own help.
|
|
env DEVVM_MESSAGES=names
|
|
! exec devvm --nope
|
|
cmp stderr nope-flag.txt
|
|
! stdout .
|
|
! exec devvm stop --nope
|
|
stderr '^devvm: flag_unknown command=devvm stop flag=--nope$'
|
|
stderr '^usage_help command=devvm stop$'
|
|
|
|
# So is a command given too many arguments, naming those its help shows.
|
|
! exec devvm build a b
|
|
cmp stderr build-args.txt
|
|
! stdout .
|
|
! stub_calls
|
|
|
|
# Flags for a new VM are devvm [IMAGE]'s alone, so other commands refuse
|
|
# them, before or after the command's name.
|
|
! exec devvm ls --cpus 4
|
|
stderr '^devvm: flag_unknown command=devvm ls flag=--cpus$'
|
|
! exec devvm --cpus 4 ls
|
|
stderr '^devvm: flag_unknown command=devvm ls flag=--cpus$'
|
|
! exec devvm restart --backend lima
|
|
stderr '^devvm: flag_unknown command=devvm restart flag=--backend$'
|
|
! exec devvm tools add node --from node:24
|
|
stderr '^devvm: flag_unknown command=devvm tools add flag=--from$'
|
|
# A backend that isn't one is refused first too.
|
|
! exec devvm build --backend nope base
|
|
stderr '^devvm: backend_unknown backends=docker, lima, smolvm name=nope$'
|
|
stderr '^usage_help command=devvm build$'
|
|
! stub_calls
|
|
|
|
# No flag or argument takes an empty value to mean none or its default.
|
|
! exec devvm --ports ''
|
|
stderr '^devvm: flag_blank flag=ports$'
|
|
! exec devvm --cpus=
|
|
stderr '^devvm: flag_blank flag=cpus$'
|
|
! exec devvm ''
|
|
stderr '^devvm: arg_blank command=devvm$'
|
|
! exec devvm history export ''
|
|
stderr '^devvm: arg_blank command=devvm history export$'
|
|
! stub_calls
|
|
|
|
-- nope-flag.txt --
|
|
devvm: flag_unknown command=devvm flag=--nope
|
|
usage_help command=devvm
|
|
-- build-args.txt --
|
|
devvm: args_too_many args=IMAGE command=devvm build given=a b
|
|
usage_help command=devvm build
|