This is the defmain Reference Manual, version 0.12.1, generated automatically by Declt version 4.0 beta 2 "William Riker" on Sun Dec 15 05:57:53 2024 GMT+0.
The main system appears first, followed by any subsystem dependency.
defmain
A wrapper around net.didierverna.clon which makes command line arguments parsing easier.
Alexander Artemenko
(GIT https://github.com/40ants/defmain)
BSD
0.12.1
uiop
(system).
defmain/defmain
(system).
defmain/changelog
(system).
defmain/defmain
Alexander Artemenko
(GIT https://github.com/40ants/defmain)
BSD
net.didierverna.clon.core
(system).
alexandria
(system).
40ants-doc
(system).
cl-strings
(system).
cl-inflector
(system).
named-readtables
(system).
pythonic-string-reader
(system).
docs-config
(system).
Files are sorted by type and then listed depth-first from the systems components trees.
defmain/defmain/file-type.lisp
defmain/defmain
(system).
@index
(special variable).
@readme
(special variable).
defcommand
(macro).
defmain
(macro).
get-subcommand-name
(function).
print-commands-help
(function).
print-help
(function).
subcommand
(function).
%call-command
(function).
%is-need-to-catch-errors
(function).
%print-commands-help
(function).
*badges*
(special variable).
@helpers
(special variable).
@installation
(special variable).
@reasoning
(special variable).
@roadmap
(special variable).
@subcommands
(special variable).
@usage
(special variable).
add-help-fields
(function).
argument-is-required-error
(condition).
cool-synopsis
(class).
extract-parent-args
(function).
get-argument-name
(reader method).
get-command
(reader method).
get-positional-args
(function).
get-program-name
(function).
get-rest-arg
(function).
get-short-description
(function).
get-value-if-symbol
(function).
help-spec
(method).
is-has-subcommand
(function).
make-binding
(function).
make-bindings
(function).
make-field-description
(function).
make-long-name
(function).
make-positional-bindings
(function).
make-postfix-string
(function).
make-short-name
(function).
make-synopsis-args
(function).
make-synopsis-fields
(function).
map-fields
(function).
defmain/changelog/file-type.lisp
defmain/changelog
(system).
@changelog
(special variable).
0.1.0
(special variable).
0.10.0
(special variable).
0.11.0
(special variable).
0.12.0
(special variable).
0.12.1
(special variable).
0.13.0
(special variable).
0.13.1
(special variable).
0.2.0
(special variable).
0.3.0
(special variable).
0.4.0
(special variable).
0.5.0
(special variable).
0.6.0
(special variable).
0.6.1
(special variable).
0.7.0
(special variable).
0.7.1
(special variable).
0.7.2
(special variable).
0.8.0
(special variable).
0.9.0
(special variable).
0.9.1
(special variable).
Packages are listed by definition order.
defmain/changelog
common-lisp
.
@changelog
(special variable).
0.1.0
(special variable).
0.10.0
(special variable).
0.11.0
(special variable).
0.12.0
(special variable).
0.12.1
(special variable).
0.13.0
(special variable).
0.13.1
(special variable).
0.2.0
(special variable).
0.3.0
(special variable).
0.4.0
(special variable).
0.5.0
(special variable).
0.6.0
(special variable).
0.6.1
(special variable).
0.7.0
(special variable).
0.7.1
(special variable).
0.7.2
(special variable).
0.8.0
(special variable).
0.9.0
(special variable).
0.9.1
(special variable).
defmain
defmain/defmain
common-lisp
.
@index
(special variable).
@readme
(special variable).
defcommand
(macro).
defmain
(macro).
get-subcommand-name
(function).
print-commands-help
(function).
print-help
(function).
subcommand
(function).
%call-command
(function).
%is-need-to-catch-errors
(function).
%print-commands-help
(function).
*badges*
(special variable).
@helpers
(special variable).
@installation
(special variable).
@reasoning
(special variable).
@roadmap
(special variable).
@subcommands
(special variable).
@usage
(special variable).
add-help-fields
(function).
argument-is-required-error
(condition).
cool-synopsis
(class).
extract-parent-args
(function).
get-argument-name
(generic reader).
get-command
(generic reader).
get-positional-args
(function).
get-program-name
(function).
get-rest-arg
(function).
get-short-description
(function).
get-value-if-symbol
(function).
is-has-subcommand
(function).
make-binding
(function).
make-bindings
(function).
make-field-description
(function).
make-long-name
(function).
make-positional-bindings
(function).
make-postfix-string
(function).
make-short-name
(function).
make-synopsis-args
(function).
make-synopsis-fields
(function).
map-fields
(function).
Definitions are sorted by export status, category, package, and then by lexicographic order.
This macro is similar to DEFMAIN macro in terms of arguments and body processing.
The only difference is that instead of the single name you have to provide a
list of two names:
- First element should be the name of the parent function.
It can be either a main entry-point or other subcommand.
- Second element is a symbol to name the subcommand.
Here is an example with of a program with two subcommands.
Pay attention to the ‘MAIN‘ function’s argument list.
It ends with a special symbol &SUBCOMMAND. It should be
provided to let macro know there will be some subcommands
defined later.
“‘
(defmain (main) ((verbose "More detail in the output")
&subcommand)
...)
(defcommand (main upload) ((upstream "Repository name")
(force "Rewrite changes in case of conflict"
:flag t))
...)
(defcommand (main sync) ()
"Yet another subcommand."
...)
“‘
All arguments, specified for the ‘MAIN‘ function also bound for all it’s subcommands.
On command-line these arguments should preceed the subcommand’s name
By default, main command run’s specified subcommand and exits, but you can use
it as a decorator, to execute some common code before and after as subcommand.
To run subcommand, execute SUBCOMMAND function:
“‘
(defmain (main) ((verbose "More detail in the output"))
(format t "Before subcommand.~%")
(defmain:subcommand)
(format t "After subcommand.~%"))
“‘
This macro let you to define a main function for a command-line program.
Usually the NAME argument will be just MAIN. This name will be bound
to a function which will process arguments and execute the BODY.
ARGS should contain an arguments definition. Each definition is a list of the form:
(NAME DESCRIPTION &KEY FLAG ENV-VAR SHORT DEFAULT)
Argument’s NAME should be a symbol. It names a variable which will be bound during
the BODY execution. Also, this name is lowercased and used to form a ‘–long‘
command line argument.
The lowercased first letter of the NAME is used as a short version of the argument,
like ‘-l‘. But sometimes you might encounter duplication errors when having
a few arguments starting from the same letter. In this case provide SHORT option,
to override the letter, used for the short option.
For example, here we have a conflict:
“‘
(defmain (main) ((version "Print program version and exit")
(verbose "Provide more detail on the output"))
...)
“‘
But we can tell DEFMAIN to use ‘-V‘ option for verbose, instead of ‘-v‘
“‘
(defmain (main) ((version "Print program version and exit")
(verbose "Provide more detail on the output" :short "V"))
...)
“‘
Also, we can pass NIL, to turn off short version for VERBOSE argument:
“‘
(defmain (main) ((version "Print program version and exit")
(verbose "Provide more detail on the output" :short NIL))
...)
“‘
If some of your options are boolean, then give it a ‘:FLAG t‘ option,
and a variable will become ‘T‘ if user provided this flag on the command-line.
Also, you might want to specify a DEFAULT value for the argument or provide
an environment variable name using ENV-VAR. The value will be take from the
environment variable unless it was provided by the user on the command-line.
Arguments list of DEFMAIN macro might end with ‘&REST SOME-VAR‘. In this case, all unprocessed command line arguments will be collected into the SOME-VAR list.
By default program name, shown in the ‘–help‘, will be the same as the name
of the function or taken as a third part of the ‘ROS.SCRIPT.THIRD-PART‘ package
name, if you are using Roswell. However, you can override it providing the
PROGRAM-NAME argument.
Returns a string with current subcommand’s name.
It should be called from the function defined with DEFMAIN macro.
Outputs information about supported subcommands.
It should be called from the function defined with DEFMAIN macro.
Outputs to stdout a help about command line utility.
Executes the current subcommand. It is called automatically at the end of the
main body unless you call it manually.
It can be called from the function defined with DEFMAIN macro.
Checks if option :catch-errors t was given to the defmacro. If not given, then it is True by default.
Outputs to stdout a help about command line utility.
Searches in the list of macro arguments a sequence like:
&parent-args (foo bar)
and returns (foo bar).
Takes a lambda list and returns a symbol, naming &rest argument, or nil.
If value is a bound symbol, then returns its bound value. For all other cases just returns a value itself.
Returns t if there is &subcommand symbol in the list.
Returns a list of forms for "let" form.
Variable args contains a list of arguments given to defmain, like:
((debug :documentation "Show traceback instead of short message.")
(log :documentation "Filename to write log to.")
&rest repository)
For this input, output will be a list like:
((debug (net.didierverna.clon:getopt :long-name "debug"))
(log (net.didierverna.clon:getopt :long-name "log")))
Returns a single fields description. Name argument is a symbol. Function returns a list.
Returns a list of forms for "let" form.
It is like make-bindings, but only returns bindings for positional arguments.
The should be separate because applied after the –help option was checked.
Checks if there is &rest or &subcommand part in defmain’s args and outputs it either as
(:postfix "REPOSITORY") list
or as
(:postfix "SUBCOMMAND") list.
Returns fields description for net.didierverna.clon:defsynopsis.
Maps given function to all given args. Args should be in the format
of defmain arguments.
Returns a list of results from each function call.
argument-is-required-error
)) ¶cool-synopsis
)) ¶A symbol of a function created by defmain macro. Used to extract information about the name of the current command and a name of subcommands.
cool-synopsis
) &key program) ¶net.didierverna.clon
.
error
.
:name
This slot is read-only.
synopsis
.
A symbol of a function created by defmain macro. Used to extract information about the name of the current command and a name of subcommands.
:command
This slot is read-only.
Jump to: | %
A D E F G H I M P S |
---|
Jump to: | %
A D E F G H I M P S |
---|
Jump to: | *
0
@
A C S |
---|
Jump to: | *
0
@
A C S |
---|
Jump to: | A C D F P S |
---|
Jump to: | A C D F P S |
---|