2021-02-05

(sph cli)

create command-line interfaces

part of sph-lib

module name

(sph cli)

exported bindings

procedure: cli-command-match arguments commands-spec ->
list list -> false/any
procedure: cli-create config ... ->
::
#:version string/(integer ...)
#:about string/procedure:{-> string}
#:description string
#:usage string
#:usage-arguments string
#:arguments (string ...)
#:null-arguments (string ....)
#:missing-arguments-handler procedure:{symbol any ...}
#:unsupported-option-handler procedure:{symbol srfi-37-option option-name ...}
#:command-handler procedure:{list:(symbol ...):command-name list:rest-arguments -> any}
#:commands commands-spec
#:command-options option-spec
#:options (option-spec ...)
option-spec ...
->
procedure:{(string ...) -> list:alist:((symbol . any) ...):parsed-arguments}

# description
null-arguments: arguments to use when no arguments have been given to the cli, for example (list \"--help\")
commands-options: options shared between commands
commands: specify sub-commands that are recognised as leading keywords in the program arguments. with options or handler procedures
command-handler: command-handler called for all commands (after individual command handlers)
options: specify long, short and unnamed options
# data-structures
custom-processor: custom handler for option values. procedure:args-fold-processor:{opt matched-name any result ->}
input-type-names: symbol:string/number/integer
option-spec: (symbol/list:name/pattern #:names character/string/(character/string ...) #:required? boolean
#:value-required? boolean #:value-optional? boolean #:type symbol #:description string #:processor procedure:custom-processor)
pattern: (symbol symbol/ellipsis:... ...)
commands-spec: (((string:command-name ...) procedure:{command arguments}/[cli-create-argument ...]) ...).
more documentation and examples can be found on http://sph.mn/computer/software/sph-lib/cli.html
variable: sph-cli-description