fix: consistent usage errors for list, leave, status, who, log

list ignored --help and listed parties; leave and status ignored stray
arguments; who silently kept the last of several positionals; log took
a positional name that neither its usage nor the man page documents.
All now follow the parser convention of the other subcommands: help on
-h, exit 2 on an unknown flag or unexpected argument.
This commit is contained in:
veg 2026-09-21 09:33:36 +00:00
parent 9b85485ee8
commit 698fff91ee
2 changed files with 43 additions and 10 deletions

View file

@ -31,3 +31,25 @@ teardown() { teardown_party_sandbox; }
# assertion is the test.
[ -n "${PARTY_VERSION:-}" ]
}
@test "no-argument subcommands print help and reject stray args" {
for sub in list leave status; do
run "$PARTY_BIN" "$sub" --help
[ "$status" -eq 0 ]
[[ "$output" == "Usage: party $sub" ]]
run "$PARTY_BIN" "$sub" stray
[ "$status" -eq 2 ]
[[ "$output" == *"unexpected arg 'stray'"* ]]
run "$PARTY_BIN" "$sub" --bogus
[ "$status" -eq 2 ]
done
}
@test "who rejects a second positional, log rejects any" {
run "$PARTY_BIN" who one two
[ "$status" -eq 2 ]
[[ "$output" == *"unexpected arg 'two'"* ]]
run "$PARTY_BIN" log one
[ "$status" -eq 2 ]
[[ "$output" == *"unexpected arg 'one'"* ]]
}