change record: accept multiple paths after --files #129
No reviewers
Labels
No labels
bug
duplicate
enhancement
help wanted
invalid
question
wontfix
bug
duplicate
enhancement
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
allod/tools!129
Loading…
Reference in a new issue
No description provided.
Delete branch "agent/files-usage-repeatable"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes allod/tools#128
allod change record's usage lines spell the staging flag[--files <file>...], which reads as "one or more values after the flag". The parser took exactly one and shifted past it, so a bare second path fell through to the catch-all and aborted withunexpected argument for change record: <path>.A flag named
--filesthat accepts exactly one file is the defect. The usage string was describing the interface a human would expect, so the parser moves to match it rather than the other way round.-f|--filesnow consumes every following argument up to the next--prefixed token.change recordtakes no positional arguments, so nothing else can be swallowed.--files a b,--files a --files b, and-f a b --files call name the same set.--files a b -m msgand-m msg --files a bare equivalent.--filesat the end of the line or--files -m msg, still dies with the existingrequires a valuewording instead of falling through to thegit add -usweep that naming no files selects.--ends option parsing, so a path beginning with-stays reachable; a bare--with nothing after it is an error for the same reason.[--files <file>...], and the prose now describes the variadic flag instead of telling the reader to give each file its own flag.The first commit on this branch took the opposite direction and edited the documentation to match the single-value parser. It stays in history; the commit after it supersedes that direction.
Risk
R1. Argument parsing for one subcommand, all of it before any git mutation. Every invocation that works on master keeps working — a lone
--files aand the repeated--files a --files bparse exactly as before — and every form this adds aborts on master, so nothing can go from working to broken. The hazard worth naming is the empty file list, which would handrecordback togit add -uand sweep another agent's tracked edits; that path is refused explicitly and covered by its own sabotage check.--is the only token whose meaning changes: it previously reached the catch-all and died as an unknown option.Validation
bash tests/allod-change.shpasses: 183 assertions, up from 159 on master. The 24 new ones cover several paths after one flag, the mixed-f a b --files cform, both flag orders with the resulting commit message asserted, the empty-list errors for--files,-f, and--, and a path literally named-dash.txtpassed after--.files+=("$2"); shift 2— fails atrecord accepts several paths after one --files.--prefixed token immediately after the flag removed — fails atrecord rejects --files followed by another option, which then commits agit add -usweep instead of erroring.--case removed — fails atrecord stages a '-'-prefixed path after --../allod change record -M <file> --files allod tests/allod-change.sh, staging both paths from one flag.allod change --helprenders the corrected usage block.Found and left alone
allod/memory'sgit-workflow.mdandallod.mdspell the flag[-f <file>...]. This makes that spelling true rather than misleading, so neither needs an edit.<file>...-style variadic backed by a single-value parser.flake-update-cascade <input-name>...is genuinely variadic, andchange submit's-F <file|->is single-valued and spelled that way.nobody writes a cli like this! it's just lazy. unacceptable.
make
files(notice it has an s at the end) accept multiple filenames. then reevaluate whatever information you ingested to make this awful decision on feature direction. think about updating your memory or documentation or whatever to prevent this kind of decision in the future. no human would ever want to use the cli you just designed. treat cli interfaces as human facing interfaces and apply some common sense ux rules before you go off and build the wrong thing again.smdh
change record: document --files as a repeatable single-value flagto change record: accept multiple paths after --filesYou are right.
--filesis plural and now takes as many paths as follow it.What changed on the branch:
-f|--filesconsumes every following argument up to the next--prefixed token. Repeating the flag still accumulates, and the forms combine:--files a b,--files a --files b, and-f a b --files call name the same set.--files a b -m msgand-m msg --files a bare equivalent.--fileswith nothing usable after it is still an error, so an empty list never falls back to thegit add -usweep, and--ends option parsing for a path that begins with-.[--files <file>...], which was accurate all along, and the prose that told you to give each file its own flag is gone.Tests are at 183 assertions, up from 159 on master, and three sabotage runs confirm the new ones fail when the parser is reverted, when the empty-list guard is dropped, and when
--is removed.Issue allod/tools#128 is corrected too: it had named the usage-string edit as the default and the variadic parser as the alternative, which was backwards.
The rule is going into
allod/memoryas acli-design.mdtopic file, separate PR: a CLI is a human-facing interface, a plural flag takes multiple values, and when usage text and behavior disagree the default is to fix the behavior. Editing docs to match a defective implementation documents the bug, and a smaller diff is not a reason to ship a worse interface.A bare
--is now a no-op rather than an error, matching the convention that--ends option parsing rather than requiring an operand.The earlier justification for erroring — that
record -m "$m" -- "${files[@]}"with an empty array falls back togit add -uand can sweep another agent's edits — was answering the wrong question.record -m "$m"with no file flags at all already does exactly that, and it is the documented default. A bare--naming nothing is the same situation, so refusing it added an inconsistency without closing the hazard.The two cases are distinct and both now behave conventionally: an option missing its value is an error, so
--filesand-fwith nothing following still fail withrequires a value; a terminator with nothing after it names no files and leaves thegit add -udefault in force.Tests are 185, up from 183. The empty-value assertions keep their "commits nothing" check, and a new case asserts a bare
--succeeds and stages both tracked files through the fallback. Sabotage-checked by restoring the error: the suite fails atnot ok 135 - record accepts a bare -- with no path.