0090. Args v1 grammar
- Status: Accepted (default; pending owner confirmation)
- Date: 2026-11-01
- Plan: M9.8 Step 8.2; D6
Context
The edition plugin set needs a pure, typed CLI parser without adding compiler syntax or capabilities. Generator entry points (ADR-0078) and imports from a generator package runtime (ADR-0084) already provide the required mechanisms. The grammar is a plugin policy and needs an explicit, reproducible v1 default.
Decision
derive Args for Options on a struct generates
options_from_args(args: vec<str>) -> result<Options, ArgsError>
and options_usage() -> str. The input excludes the
executable name. The plugin declares
capabilities = []; ArgsError lives in
args.rt with a message field.
strandi64fields require--name value. Integers are checked signed decimal values; malformed or out-of-range values are errors, never traps.booldefaults to false; the flag's presence sets it to true.option<str>andoption<i64>default to none; a flag supplies some(value).- At most one
vec<str>collects positionals in input order. Empty tokens and a lone-are positionals; other dash-prefixed tokens are flags. - Field underscores become hyphens (
max_linesbecomes--max-lines). Usage lists fields in declaration order: required--name <type>, optional[--name <type>], boolean[--name], positional[field...]. - Unknown flags, duplicate flags (including booleans), missing
required flags, missing values and positionals without a collector
return clear errors. A value beginning
--counts as missing; negative integers remain valid. - Any other field type, or a second positional collector,
returns E0966 with the exact
Type.fieldpath. Non-struct targets are rejected with their name.
V1 deliberately excludes short flags, --x=v,
subcommands and repeated flags. There is no --
terminator, automatic help flag, implicit process-argument access
or option-value escaping convention.
Alternatives
- A full CLI framework with aliases, subcommands and repeat policies expands the grammar and testing surface before the three-plugin milestone needs it.
- Compiler-native argument parsing would make this policy part of the kernel; a capability-free generator and runtime record already suffice.
- Silently ignoring unknown flags or accepting last-wins duplicates hides input mistakes; explicit result errors keep behavior deterministic and visible.
Consequences
Both backends run the same generated Harness parser. Callers
control argument acquisition and error presentation. Usage is
stable and deliberately compact. Literal values starting
-- cannot be supplied in v1. Grammar extensions need
a later decision rather than silently changing these defaults.