Next: Introduction, Previous: (dir), Up: (dir) [Contents][Index]
This is the cl-argparse Reference Manual, generated automatically by Declt version 4.0 beta 2 "William Riker" on Mon Aug 15 03:27:58 2022 GMT+0.
Next: Systems, Previous: The cl-argparse Reference Manual, Up: The cl-argparse Reference Manual [Contents][Index]
A common lisp cmd argument parser inspired by python argparse
None
create-main-parser (var &optional description) elements*
=> parser
Create a parser with the given name and the variable of name
create-sub-parser (name &optional description) elements*
=> parser
Create a parser with the given name and the variable of name
add-flag parser &key short long help var
Add a flag to the current parser
add-optional parser &key short long default help var
Add a parameter to the current parser
add-positional parser &key name help
Add a positional argument to the parser
add-subparser parser subparser
adds a subparser to the parser
add-generic-parser parser gen
adds the parsing elements of the gen parser to the given parser
add-default parser &key var default
adds a default value to the parser
get-value name parser
get the cmd provided variable value of name from parser
parse parser argv
parse the stringlist argv using parser parser
create-mockup-parser key-value-list*
create a parser simulating a parsing resulting in the given key-value-list
You can either use the short example below to get started or the longer example provided as commented source code in ./src/examples/example.lisp
.
(in-package :cl-argparse)
(format t "~a~%"
(parse
(create-main-parser (main-parser "here comes the description of the program")
(add-flag main-parser :short "g" :long "goo" :help "this is an example flag" :var "goo")
(add-optional main-parser :short "t" :long "test" :help "this is an example optional argument" :var "test")
(add-positional main-parser :name "pos" :help "this is an example for a positional")
(add-subparser main-parser (create-sub-parser (sub "this is a sub action parser")
(add-positional sub :name "action" :help "this is an example for a positional"))))
(list "-g" "-t" "alle" "positional" "sub" "theaction")))
=> <PARSER
goo -> T
test -> alle
pos -> positional
action -> theaction
>
Next: Files, Previous: Introduction, Up: The cl-argparse Reference Manual [Contents][Index]
The main system appears first, followed by any subsystem dependency.
A python argparse inspired command line parser library
Simon Koch <projects@halcony.de>
Simon Koch <projects@halcony.de>
MIT
Next: Packages, Previous: Systems, Up: The cl-argparse Reference Manual [Contents][Index]
Files are sorted by type and then listed depth-first from the systems components trees.
Next: cl-argparse/package.lisp, Previous: Lisp, Up: Lisp [Contents][Index]
cl-argparse (system).
Next: cl-argparse/classes.lisp, Previous: cl-argparse/cl-argparse.asd, Up: Lisp [Contents][Index]
cl-argparse (system).
Next: cl-argparse/methods.lisp, Previous: cl-argparse/package.lisp, Up: Lisp [Contents][Index]
package.lisp (file).
cl-argparse (system).
Previous: cl-argparse/classes.lisp, Up: Lisp [Contents][Index]
cl-argparse (system).
Next: Definitions, Previous: Files, Up: The cl-argparse Reference Manual [Contents][Index]
Packages are listed by definition order.
cl-argparse
Next: Indexes, Previous: Packages, Up: The cl-argparse Reference Manual [Contents][Index]
Definitions are sorted by export status, category, package, and then by lexicographic order.
Next: Internals, Previous: Definitions, Up: Definitions [Contents][Index]
Next: Generic functions, Previous: Public Interface, Up: Public Interface [Contents][Index]
Macro for creating the main parser. Always names the parser main-parser (required for parsing
to work) and adds the help flag. Allows to add further parameters to the parser. Returns the parser
at the end
Macro for creating a sub parser, provides name as the subparser name to the help message, adds a help flag and allows to add further parameters to the parser. Returns the parser at the end.
Next: Standalone methods, Previous: Macros, Up: Public Interface [Contents][Index]
Adds a flag to the given parser using short as the short value of the flag (has to be lead with a single - in the argument list. The var determines the name under which it is stored in the parser value table. long determines the long version of the flag (lead with two -) and help is the help string used to generate the help message
Adds an optional value to the given parser. short is the to be used parameter name (with a single leading -). Var is the name under which to store the value in the parser table. long is the long version of the name (lead with two –). Default determines the default value and help is the help message string to be used in the auto generated help message
Adds a positional argument to the given parser. Name is both the name of the positional used in the help message as well as the name under which the value is stored. Help defines the string to be used in the auto generated help message
Next: Conditions, Previous: Generic functions, Up: Public Interface [Contents][Index]
Next: Classes, Previous: Standalone methods, Up: Public Interface [Contents][Index]
simple-error.
(quote "")
:format-control
This slot is read-only.
(quote (list))
:format-arguments
This slot is read-only.
Previous: Conditions, Up: Public Interface [Contents][Index]
"no description"
:description
This slot is read-only.
"program.lisp"
:program-name
This slot is read-only.
(list)
This slot is read-only.
(list)
This slot is read-only.
(list)
This slot is read-only.
(make-hash-table :test (quote equalp))
This slot is read-only.
Previous: Public Interface, Up: Definitions [Contents][Index]
Next: Ordinary functions, Previous: Internals, Up: Internals [Contents][Index]
allows for the creation of a mockup parser to enable creating a parser without actually parsing command line parameters
Next: Generic functions, Previous: Macros, Up: Internals [Contents][Index]
merges table-b into table-a
Next: Conditions, Previous: Ordinary functions, Up: Internals [Contents][Index]
automatically generated reader method
automatically generated reader method
Tries to parse (car argv) using the passed flag (i.e., help flag). If the flag is successfully parsed the help-flag-condition is signaled, else argv and nil is returned.
Given a parser and a list of strings this method extracts the provided
flags and optional parameters and enters them into the parser table.
It returns the remaining list. The parsing either stops if all optionals
or flags of the parser a filled or if the currently viewed list element does
not match either an optional or flag.
Parses a positional argument, i.e., (car argv) and stores it in the given table. Throws an error in case no value is contained in argv. Returns (cdr argv) as it either always works or has to throw an error.
Next: Classes, Previous: Generic functions, Up: Internals [Contents][Index]
simple-error.
(quote "")
:format-control
This slot is read-only.
(quote (list))
:format-arguments
This slot is read-only.
simple-error.
Previous: Conditions, Up: Internals [Contents][Index]
:help-message
This slot is read-only.
:help-message
This slot is read-only.
:help-message
This slot is read-only.
Previous: Definitions, Up: The cl-argparse Reference Manual [Contents][Index]
Jump to: | A C D F G H L M N O P S T V |
---|
Jump to: | A C D F G H L M N O P S T V |
---|
Next: Data types, Previous: Functions, Up: Indexes [Contents][Index]
Jump to: | D F H L N O P S T V |
---|
Jump to: | D F H L N O P S T V |
---|
Jump to: | C D F H M O P S |
---|
Jump to: | C D F H M O P S |
---|