This is the whereiseveryone.command-line-args Reference Manual, version 0.1.1, generated automatically by Declt version 4.0 beta 2 "William Riker" on Sun Dec 15 08:05:46 2024 GMT+0.
The main system appears first, followed by any subsystem dependency.
whereiseveryone.command-line-args
Automatically create a command-line-argument parser for a given Common Lisp function definition.
Jorge & Charles
AGPL v3 or any later version
Command-Line-Args provides a main macro (‘command’) that wraps a ‘defun’ form and creates a new function that parses the command line arguments. It has support for command-line options, positoinal, and variadic arguments. It also generates a basic help message. The interface is meant to be easy and non-intrusive.
0.1.1
alexandria
(system).
serapeum
(system).
str
(system).
charje.documentation
(system).
trivia
(system).
package.lisp
(file).
conditions.lisp
(file).
command-line-args.lisp
(file).
Files are sorted by type and then listed depth-first from the systems components trees.
whereiseveryone.command-line-args/whereiseveryone.command-line-args.asd
whereiseveryone.command-line-args/package.lisp
whereiseveryone.command-line-args/conditions.lisp
whereiseveryone.command-line-args/command-line-args.lisp
whereiseveryone.command-line-args/whereiseveryone.command-line-args.asd
whereiseveryone.command-line-args
(system).
whereiseveryone.command-line-args/package.lisp
whereiseveryone.command-line-args
(system).
whereiseveryone.command-line-args/conditions.lisp
package.lisp
(file).
whereiseveryone.command-line-args
(system).
combined-flag
(reader method).
command-line-condition
(condition).
flag
(reader method).
invalid-combined-short-flag
(condition).
invalid-flag
(condition).
invalid-subcommand
(condition).
invalid-variadic-parser
(condition).
keyword-argument-too-short
(condition).
maximum-number-of-args
(reader method).
minimum-number-of-args
(reader method).
number-of-args-supplied
(reader method).
parser
(reader method).
rest-used-for-variadic
(condition).
subcommand
(reader method).
wrong-number-of-args
(condition).
arg
(reader method).
param
(reader method).
parameter-name
(reader method).
parser-name
(reader method).
whereiseveryone.command-line-args/command-line-args.lisp
conditions.lisp
(file).
whereiseveryone.command-line-args
(system).
command
(macro).
parse-boolean
(function).
subcommand-case
(macro).
*command-line-args*
(special variable).
*command-line-invocation*
(special variable).
check-variadic-parameter-parser
(function).
combined-short-flags-p
(function).
commandify
(function).
flag-match-p
(function).
flagp
(function).
generate-argument-parser
(function).
generate-check-argument-lengths
(function).
generate-help
(function).
generate-keyword-args-parser
(function).
help-time-p
(function).
increment-boolean-counter
(macro).
last-parameter
(function).
parse-flag-declarations
(function).
parse-optional-args-let-bindings
(function).
parse-parser-declarations
(function).
parse-required-args-let-bindings
(function).
print-paragraph
(function).
short-form-flag
(function).
subcommand-cases
(function).
Packages are listed by definition order.
whereiseveryone.command-line-args
common-lisp
.
combined-flag
(generic reader).
command
(macro).
command-line-condition
(condition).
flag
(generic reader).
invalid-combined-short-flag
(condition).
invalid-flag
(condition).
invalid-subcommand
(condition).
invalid-variadic-parser
(condition).
keyword-argument-too-short
(condition).
maximum-number-of-args
(generic reader).
minimum-number-of-args
(generic reader).
number-of-args-supplied
(generic reader).
parse-boolean
(function).
parser
(generic reader).
rest-used-for-variadic
(condition).
subcommand
(generic reader).
subcommand-case
(macro).
wrong-number-of-args
(condition).
*command-line-args*
(special variable).
*command-line-invocation*
(special variable).
arg
(generic reader).
check-variadic-parameter-parser
(function).
combined-short-flags-p
(function).
commandify
(function).
flag-match-p
(function).
flagp
(function).
generate-argument-parser
(function).
generate-check-argument-lengths
(function).
generate-help
(function).
generate-keyword-args-parser
(function).
help-time-p
(function).
increment-boolean-counter
(macro).
last-parameter
(function).
param
(generic reader).
parameter-name
(generic reader).
parse-flag-declarations
(function).
parse-optional-args-let-bindings
(function).
parse-parser-declarations
(function).
parse-required-args-let-bindings
(function).
parser-name
(generic reader).
print-paragraph
(function).
short-form-flag
(function).
subcommand-cases
(function).
Definitions are sorted by export status, category, package, and then by lexicographic order.
Define a function that parses the command line arguments for and
then calls the funciton defined by DEFUN.
DEFUN: A typical ‘defun’ form. It is evaluated to define the
function as usual.
The new function generated will be the same as the function defined
by the DEFUN with a -command suffix. Feel free to use this for the
entry-point of your executable or script.
‘&key’ parameters become command line options. These are parsed
first, before required parameters. Each option will have a long
form and a short form (if it is not already taken by another
parameter). The long form is the whole name of the parameter
preceded by 2 hyphens. The short form is the first letter of the
parameter preceded by a single hyphen. In either case the option
and the actual argument are separated by a space on the command
line. The short flag customized by using a ‘flag’ declaration as
follows:
(command
(defun custom-short-flag (&key some-option)
(declare (flag #o some-option))
...)
That will make it so that the -o option argument is the
‘some-option’ argument.
Most keyword parameters will take an argument. Using
‘parse-boolean’ as a parser for a parameter makes it not take an
argument. If the command line option is not present the value will
be ‘nil’, else if it is present it will be the number of time the
command line option appeared.
For a variadic parameter, do not use ‘&rest’. Instead declare the
parser like so:
(command
(defun variadic-function (variadic-param)
(declare (parser (list parse-integer)
variadic-param))
...))
That will a variable number of integer from the command line
arguments. Note only the last positional argument can be
variadic. To have a variadic parameter without any special parser
(just plain strings) use the following parser:
(declare (parser (list identity) variadic-parameter)).
Use for a command to dispatch onto another command by the first
argument. If SUBCOMMAND matches any of the symbol-names (lowercased)
of the CASES, call the related command.
SUBCOMMAND: The user provided variable which selects which
subcommand to execute. It should be the one and only positional
argument for comamnds where ‘subcommand-case’ is used. It should be
raw user input and not mutated or cleaned up at all.
SUBCOMMANDS: A list of function names all of which should be
defined inside of a ‘command’.
You may be tempted to just use your own ‘cond’, but using using
‘subcommand-case’ will ensure that documentation is generated for
your subcommands.
When SUBCOMMAND does not match any of SUBCOMMANDS, an ‘invalid-subcommand’ is signaled. You can handle this condition to customize the behavior of a mismatched subcommand.
Parse ARG as a shell Boolean. Only return ‘t’ for non empty strings.
ARG: The thing to be parsed. Parsing will not be attempted for non-strings.
invalid-combined-short-flag
)) ¶invalid-flag
)) ¶flag
.
wrong-number-of-args
)) ¶wrong-number-of-args
)) ¶wrong-number-of-args
)) ¶invalid-variadic-parser
)) ¶invalid-subcommand
)) ¶The parent conditio for the ‘whereiseveryone.command-line-args’ system.
condition
.
This is when the user of the command line provides an invalid flag that in the form of a combined short flag: (-abcd) where a, b, c, and d are all different arguments and one of them is not valid for this command.
The combined short flag the contains the invalid flag.
:combined-flag
This slot is read-only.
This is when a user of the command line tried to provide a command line option that this command has not been defined to handle.
command-line-condition
.
error
.
flag
.
This is when the user of the command line provides a subcommand that doesn’t match any of the subcommands.
command-line-condition
.
error
.
The user supplied subcommand that does not match any of the subcommands that this command is designed to handle.
:subcommand
This slot is read-only.
This is when the programmer declares variadic parser for a parameter which cannot be variadic due to its position in the lambda-list.
command-line-condition
.
error
.
The parameter that was declared as variadic but cannot be for whatever reason.
:param
This slot is read-only.
This is when the programmer defines a function with a keyword parameter whos argument is too short. Very short keyword arguments get confusing when it comes to short options versus long options.
command-line-condition
.
style-warning
.
arg
.
This is when ‘&rest’ is used in the ‘command’ macro. There is no sane way to map the Common Lisp concept of ‘&rest’ to the shell concept of variadic arguments. This is because the Common Lisp ‘&rest’ includes the keyword arguments.
command-line-condition
.
warning
.
The name of the ‘&rest’ parameter.
:parameter-name
This slot is read-only.
The parser declared for the ‘&rest’ parameter.
:parser-name
This slot is read-only.
This is when the user of the command line provided too few or too many arguments for this command to handle.
command-line-condition
.
error
.
The number of arguments supplied by the user of the command line tool at run time.
:supplied
This slot is read-only.
The minimum number of positional arguments that this command can take.
:min
This slot is read-only.
The maximum number of positional arguments that this command can take. ‘nil’ indicates that there is no maximum and the command can take any number of positional arguments greater or equal to the ‘minimum-number-of-args’.
(quote nil)
:max
This slot is read-only.
Parse all the custom parser declarations.
DECLARATIONS: A list of all the declare forms.
Returns a hash table where the keys are the names of the function
parameters and the values are the names of the parser functions.
keyword-argument-too-short
)) ¶arg
.
invalid-variadic-parser
)) ¶rest-used-for-variadic
)) ¶rest-used-for-variadic
)) ¶Jump to: | A C F G H I L M N P S |
---|
Jump to: | A C F G H I L M N P S |
---|
Jump to: | *
A B C F M N P S |
---|
Jump to: | *
A B C F M N P S |
---|
Jump to: | C F I K P R S W |
---|
Jump to: | C F I K P R S W |
---|