[CLI]SpecThe declarative spec. Builder methods return self, so a whole tool declares in one chain; parse / parseFrom: do the work.
var cli = [CLI]Spec.new:'greet' about:'says hello' cli.flag:'shout' short:'s' help:'LOUDLY' cli.positional:'name' help:'whom to greet' var args = cli.parseFrom:#( '-s' 'quoin' ) #( (args.at:'name') (args.flag?:'shout') ) "* -> #(quoin true)
A spec for the tool name (the usage line's first word).
A spec with a one-line description for the help text.
Flags default false, options to their default; a missing required: option is a UsageError.
A subcommand: the block configures its own sub-spec (options, positionals, rest — not further commands). The first positional token picks the command; after it, option lookups try the sub-spec first, then this one.
See command:spec:.
A boolean flag: absent -> false, --name (or its short) -> true.
See flag:.
See flag:.
The generated help: a usage line, the about text, and aligned tables of commands, options, and positionals (from their help: strings). What -h/--help prints.
Internal: the collections default empty (new:{} populated the scalars).
Every name at: may read on a result from this spec.
An option taking a value: --name value or --name=value. Absent -> its default: (nil without one), unless required:true.
See option:.
See option:.
An option that must be given (absence is a UsageError).
See option:.
The kitchen sink — every option property, nil where unused.
See option:.
See option:required:help:.
See option:values:help:.
An option whose value must be one of values: (anything else is a UsageError naming the choices).
Parse Runtime.arguments — the production entry: -h/--help prints the help and exits 0; misuse prints the message + usage to stderr and exits 2.
Parse an explicit token List, throwing UsageError on misuse — the testable seam. -h/--help short-circuits: the result answers help? and nothing else is validated.
A required positional argument (assigned in declaration order).
See positional:.
The trailing splat: every positional after the declared ones, as a List (possibly empty). Without one, extras are a UsageError.
Record one option token; answers the index after any consumed value.