8.16.0.1
Extensible Command Line
(require command-line-ext) | package: command-line-ext |
This library defines a more extensible version of command-line that supports command line flag expanders, allowing users to abstract over common command line flag patterns. This library also comes batteries-included with many pre-defined expanders for commmon patterns such as switches that toggle boolean parameters.
Source code is available at https://github.com/jackfirth/command-line-ext
1 Core Forms
syntax
(command-line-ext maybe-name flag-clause ... final-clause)
Like command-line, but with a few important differences.
In addition to the normal options for flag-clause that
command-line allows, a flag clause may also be of the
form (begin-flags flag-clause ...), which has exactly
the same semantics as if each flag-clause contained
within begin-flags was spliced into the surrounding
list of flag clauses. Additionally, command-line-ext
supports command line flag expanders, which are similar
to match expanders and allow a user to extend the
grammar of flag-clause. A custom flag-clause
created with define-command-line-flag-expander can
expand to multiple flag clauses by using begin-flags.
syntax
(define-command-line-flag-expander id transformer-expr)
Binds id as a command line flag expander. When
(id expr ...) appears as a flag-clause in
command-line-ext, a syntax object representing
(id expr ...) is passed to transformer-expr,
which must be an expression that evaluates to a procedure of
one argument at phase 1. Whatever syntax object transformer-expr
returns is then used in place of (id expr ...) as a
flag-spec.