This is the cli-parser Reference Manual, version 0.1, generated automatically by Declt version 4.0 beta 2 "William Riker" on Sun Dec 08 16:48:30 2024 GMT+0.
The main system appears first, followed by any subsystem dependency.
cli-parser
A command-line argument parser. Mostly parses options of the same form that getopt parses
Denis Bueno
Copyright (c) 2005
0.1
cli-parser.lisp
(file).
Files are sorted by type and then listed depth-first from the systems components trees.
cli-parser/cli-parser.lisp
cli-parser
(system).
cli-formatted-options
(function).
cli-option
(class).
cli-option-abbr
(reader method).
(setf cli-option-abbr)
(writer method).
cli-option-description
(reader method).
(setf cli-option-description)
(writer method).
cli-option-example
(reader method).
(setf cli-option-example)
(writer method).
cli-option-full
(reader method).
(setf cli-option-full)
(writer method).
cli-option-requires-arguments
(reader method).
(setf cli-option-requires-arguments)
(writer method).
cli-parse
(function).
cli-parse-assoc
(function).
cli-parse-hash
(function).
cli-usage
(function).
print-object
(method).
*double-dash*
(special variable).
*for-example-text*
(special variable).
*option-value-sep*
(special variable).
*single-dash*
(special variable).
abbr->full-opt-name
(function).
abbr-opt-p
(function).
cli-parse-assoc-aux
(function).
cli-parse-hash-aux
(function).
coalesce-options
(function).
coalesce-options-aux
(function).
end-opt-name
(function).
formatted-option-string
(function).
full-opt-p
(function).
opt-name
(function).
opt-p
(function).
opt-values
(function).
pprint-clos-class
(macro).
st-closest-val
(function).
st-first-val
(function).
st-rest-of
(function).
string-tokenize
(function).
string-tokenize-aux
(function).
to-full-opt-name
(function).
to-full-opt-names
(function).
Packages are listed by definition order.
cli-parser
Used for command-line-interface parsing, in the same tradition
as getopt, but, a bit more convenient. The three main functions
are:
* CLI-PARSE
* CLI-PARSE-HASH
* CLI-PARSE-ASSOC
CLI-PARSE actually just calls CLI-PARSE-HASH, which will parse a
list of command-line arguments against a list of CLI-OPTION
objects. CLI-PARSE-ASSOC, instead of returning a hash table of
results like CLI-PARSE-HASH does, returns an assoc list of
results.
The idea is that you create a bunch of cli-option instances (via MAKE-CLI-OPTION) which represent all of the valid options the user may pass in to your program. The actual options passed in (as a list of strings, one for each option) along with the list of valid options are passed to cli-parse, which will give you a table of mappings, from the option to the setting specified by the user.
common-lisp
.
common-lisp-user
.
cli-formatted-options
(function).
cli-option
(class).
cli-option-abbr
(generic reader).
(setf cli-option-abbr)
(generic writer).
cli-option-description
(generic reader).
(setf cli-option-description)
(generic writer).
cli-option-example
(generic reader).
(setf cli-option-example)
(generic writer).
cli-option-full
(generic reader).
(setf cli-option-full)
(generic writer).
cli-option-requires-arguments
(generic reader).
(setf cli-option-requires-arguments)
(generic writer).
cli-parse
(function).
cli-parse-assoc
(function).
cli-parse-hash
(function).
cli-usage
(function).
*double-dash*
(special variable).
*for-example-text*
(special variable).
*option-value-sep*
(special variable).
*single-dash*
(special variable).
abbr->full-opt-name
(function).
abbr-opt-p
(function).
cli-parse-assoc-aux
(function).
cli-parse-hash-aux
(function).
coalesce-options
(function).
coalesce-options-aux
(function).
end-opt-name
(function).
formatted-option-string
(function).
full-opt-p
(function).
opt-name
(function).
opt-p
(function).
opt-values
(function).
pprint-clos-class
(macro).
st-closest-val
(function).
st-first-val
(function).
st-rest-of
(function).
string-tokenize
(function).
string-tokenize-aux
(function).
to-full-opt-name
(function).
to-full-opt-names
(function).
Definitions are sorted by export status, category, package, and then by lexicographic order.
See CLI-PARSE-HASH.
Parses command-line arguments much in the same format as the cl-args that getopt() parses. That is, if you call any program with: ’./prgm –opt1=value1 value2 -n’, and you give "–opt1=value1", "value2" and "-n" to cli-parse-assoc, it returns and assoc-list of the form (("opt1" ("value1" "value2")) ("n" nil)).
Parses command-line arguments in the same form as specified for CLI-PARSE-ASSOC, but returns a hash-table of the results, instead of an assoc list.
Print the command line usage
cli-option
)) ¶automatically generated reader method
cli-option
)) ¶automatically generated writer method
cli-option
)) ¶automatically generated reader method
cli-option
)) ¶automatically generated writer method
cli-option
)) ¶automatically generated reader method
cli-option
)) ¶automatically generated writer method
cli-option
)) ¶automatically generated reader method
cli-option
)) ¶automatically generated writer method
cli-option
)) ¶automatically generated reader method
cli-option
)) ¶automatically generated writer method
(or null string)
:abbr
string
:full
(member nil t :optional)
:requires-arguments
string
"default description."
:description
string
:example
Long option prefix.
String used to display for example.
String used to separate option values.
Short option prefix.
Pretty print the SLOTS of a CLOS class INSTANCE, to
STREAM.
INTER-SLOT-NEWLINE-STYLE and INTRA-SLOT-NEWLINE-STYLE may be any
value appropriate appropriate as the first argument to
PPRINT-NEWLINE. A newline of INTER-SLOT-NEWLINE-STYLE will be
printed between each of the slot-name/slot-value pairs of each
slot in SLOTS. A newline of INTRA-SLOT-NEWLINE-STYLE will be
printed between the slot-name and the slot-value of each slot
in SLOTS.
UNBOUND-MSG should be a string which will be printed as the
slot-value for any slot in INSTANCE which is unbound.
SLOT-VALUE-CALLBACK should be a function of two arguments, the
slot-name and the slot-value, which should return an object
which will be printed in place of the slot-value for
slot-name.
Example:
> (defclass foo () (a b))
#<STANDARD-CLASS FOO>
> (defmethod cl:print-object ((f foo) stream)
(pprint-clos-class f (a b) stream))
#<STANDARD-METHOD PRINT-OBJECT (FOO T) {4865E569}>
> (make-instance ’foo)
#<FOO :A <unbound> :B <unbound>>
> (setf (slot-value * ’a) ’bar)
BAR
> **
#<FOO :A BAR :B <unbound>>
Converts an abbreviated option (i.e. "o") to its corresponding full option name. Returns the argument if no conversion is performed.
Test whether opt is a short option of the form "-o[=val]"
Helper for cli-parse.
Will convert a list of the form ("–option-name=val1[,]" "val2[,]" " ... "valn" ...) to a list of the form ("–option-name=val1 val2 val3" ...).
Helper for coalesce-options.
Returns the index of the end of the option-name. For example, end-opt-name would return 6 for the option "–opt1=val1"
Test whether opt is a long option of the form "–opt[=val]"
Extract the name of an option: for example "opt1" is the name from "–opt1=val1". Will return the argument if it is neither.
Evaluates to true if opt is an abbreviated or a full option.
Extract the values of an option: for example "val1" is the value from "–opt1=val1". If no values are specified, this function returns nil.
Returns the character in the string which both matches any of the val-separators and minimizes the distance between it and the index 0 of the string. If there is no match, returns the length of the string.
Returns the first token by parsing str. Analagous to car, but for the string tokenizer, instead of for lists.
Returns the rest of the string, not including the first
token. Analagous to cdr, but for the string tokenizer, instead of for
lists.
Breaks up a given string into string components by splitting the string every time an element of val-separator is encountered. Returns a list of strings, which are all the tokens. If include-separators is non-nil, the separators themselves will be included in the parse.
Helper for string-tokenize.
Convert an option name to the full one, if necessary. Change "o" to "outfile", for example.
Converts any abbreviated option list of command-line options to the full option name.
Jump to: | (
A C E F G M O P S T |
---|
Jump to: | (
A C E F G M O P S T |
---|
Jump to: | *
A D E L S |
---|
Jump to: | *
A D E L S |
---|
Jump to: | C F P S |
---|
Jump to: | C F P S |
---|