Added
- Short options may be clustered and values attached:
-vv,-vn 3,
-n3,-n=3,-vn3. The first value-taking option in a cluster
swallows the rest of the token. A cluster whose first letter is not an
option is still reported as an unknown option parsed-errorsreturns the usage errors recorded during a parse, as a
list of strings ('()when clean); subcommand errors are included- An
(error . proc)entry in therun-clihandlers alist takes over
usage-error reporting --ends option parsing; every later token is positional data- Top-level options are accepted after the subcommand token
(mytool build -n 5); a subcommand option of the same name wins there
Changed
cli,command,flag,option, andargumentvalidate their
arguments and raise with a message naming the builder: names and
descriptions must be strings, a short name is-plus one character,
a long name is--plus a name without=, command and argument names
are non-empty and do not start with-, option, argument, and
command names are unique within one level, and an argument may not
share a name with a command at the same level. A malformed spec used to
crash at the first invocation or halfway through a help page, or store
values under a mangled key; a duplicate long name cross-wired the two
optionsflagandoptionraise an error when given the reserved name-h
or--help. Declaring--helpused to store the value under the
"help"key that dispatch checks, so every invocation printed help- Every help page now has an Options section with the
-h, --helprow
and says[options]in its usage line, including pages for specs that
declare no options of their own;-hwas already accepted there run-cliexits with status 2 on a usage error, after printing each
message and a--helphint to stderr. Previously every error path
exited 0- A declared command with no handler entry, or an app with no commands
and no#fhandler, now raises an error inrun-cliinstead of
printing "Unknown command" or the help page and exiting 0 - With commands declared but no
#fhandler, invoking the app without a
command is a "missing command" usage error rather than a silent help
page
Fixed
- The library, test suite, and example use only identifiers from the
libraries they import: the suite now imports(scheme process-context)
forexit, the example imports(scheme char)and uses its
string-upcaseinstead of a hand-rolled copy, and the library no longer
redefines the importedlist-ref. Verified under Chibi Scheme, which
enforces R7RS import partitioning; CI now runs the suite there too generate-helpwith a subcommand name that is not declared raises
generate-help: no such commandinstead of printing the app's page
under the unknown name, as if the command existed- Unknown options (
--bogus,-z) and, in a commands-only app, unknown
commands are reported instead of silently dropped - Positionals beyond the declared ones are reported as unexpected
arguments instead of silently discarded - An option with no usable value (
-nat the end of argv,-n -v) is
reported; it still keeps its default - Top-level options after the subcommand token were dropped, and their
values shifted the subcommand's positionals --was silently dropped, so a dash-leading positional could never be
passed;-5alone was dropped too- A multi-character dash token whose first letter is not an option
(-foo) is reported as an unknown option; it used to be accepted as
positional data --flag=value(e.g.--verbose=true) no longer crashes the parser;
the value part is ignored and the flag is set to#t- Option values no longer consume option-shaped tokens:
-n -vnow sets
theverboseflag instead of makingcountthe string"-v", and the
same guard applies to--helpand--. Negative numbers (-5) and a
lone-are still accepted as values - Documented numeric coercion in the README: a non-numeric value for a
numeric option keeps the raw string (--count=abc→"abc"), and
full Scheme number syntax is accepted (1e3,1/2,#x10) - The greeter example's
farewellsubcommand printedGoodbye, #f!when no
name was given
Full Changelog: v0.1.1...v0.2.0