The cl-getopt Reference Manual

Next: , Previous: , Up: (dir)   [Contents][Index]

The cl-getopt Reference Manual

This is the cl-getopt Reference Manual, generated automatically by Declt version 4.0 beta 2 "William Riker" on Thu Sep 15 03:48:41 2022 GMT+0.

Table of Contents


1 Introduction

cl-getopt is a Common Lisp CFFI wrapper to the libc utility
"getopt_long".

See example.lisp for an example SBCL script using this library.  To
run the example, follow the instructions at the top of the script to
install it and then run

./example.lisp

with whatever options you want to see.  Note that for old systems
/usr/bin/env won't support the "-S" option which makes it difficult to
pass arguments to sbcl as a script.  In this case you are probably
already familiar with how to run Lisp scripts in some other way, but
if you're not then the general rule is to create an ordinary shell
script and call SBCL with whatever arguments you like rather than
exploiting the hash-bang script syntax.

There is an "install" target in the Makefile if you want to place the
cl-getopt SBCL core file somewhere it will be useful for other
scripts, e.g. genpass (https://www.github.com/ghollisjr/genpass).

cl-getopt is in the public domain.


2 Systems

The main system appears first, followed by any subsystem dependency.


Previous: , Up: Systems   [Contents][Index]

2.1 cl-getopt

CFFI wrapper to the libc getopt_long function

Author

Gary Hollis

License

Public Domain

Defsystem Dependency

cffi-grovel (system).

Dependency

cffi (system).

Source

cl-getopt.asd.

Child Components

3 Files

Files are sorted by type and then listed depth-first from the systems components trees.


Previous: , Up: Files   [Contents][Index]

3.1 Lisp


Next: , Previous: , Up: Lisp   [Contents][Index]

3.1.1 cl-getopt/cl-getopt.asd

Source

cl-getopt.asd.

Parent Component

cl-getopt (system).

ASDF Systems

cl-getopt.


3.1.2 cl-getopt/package.lisp

Source

cl-getopt.asd.

Parent Component

cl-getopt (system).

Packages

cl-getopt.


3.1.3 cl-getopt/grovel.lisp

Dependency

package.lisp (file).

Source

cl-getopt.asd.

Parent Component

cl-getopt (system).


Previous: , Up: Lisp   [Contents][Index]

3.1.4 cl-getopt/cl-getopt.lisp

Dependency

grovel.lisp (file).

Source

cl-getopt.asd.

Parent Component

cl-getopt (system).

Public Interface
Internals

4 Packages

Packages are listed by definition order.


Previous: , Up: Packages   [Contents][Index]

4.1 cl-getopt

Source

package.lisp.

Use List
  • cffi.
  • common-lisp.
Public Interface
Internals

5 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


Next: , Previous: , Up: Definitions   [Contents][Index]

5.1 Public Interface


5.1.1 Ordinary functions

Function: getopt (args options &key command-arg-present-p)

Returns the values

* option-values
* remaining-arguments

given the list of input arguments and options specification.
option-values is hash-table of the short or long argument name
string (short if present) and the list of all supplied values of that
option in the order they were given. remaining-arguments is a list of
the remaining arguments after processing the options.

Note that if no argument is supplied to an option, whether because the
argspec is :none or :optional, there will still be a list of NIL
elements for each time the option was supplied without an argument.
When the argspec is :required, some kind of value must be in the
argument list for each time that option was supplied.

options should be a list of plists, each plist of the form (&key long
short argspec description) where

* long is a symbol, string or character naming the long argument name.
* short is a symbol, string or character naming the short argument name.
* argspec is one of the values :none, :required, :optional.
* description is a string to be used in an automatically generated argument description message.

command-arg-present-p should be T whenever the argument list includes
the command as the first element, and NIL when it’s not included. For
general scripting use it should be present, but this option is
included to allow easier use of getopt for parsing argument lists
without the command being present.

Package

cl-getopt.

Source

cl-getopt.lisp.

Function: option-descriptions (options &key column-width column-minspace)

Generates a description string for the list of options supplied.

column-width controls the width in characters of each option column. column-minspace controls the minimum space to pad between columns.

Package

cl-getopt.

Source

cl-getopt.lisp.


5.2 Internals


Next: , Previous: , Up: Internals   [Contents][Index]

5.2.1 Macros

Macro: with-foreign-args ((argc argv) args &body body)

Converts a Lisp list of strings denoting the arguments supplied to a command into two values:

* argc: number of argument strings
* argv: array of argument strings

These are bound to the symbols supplied in the (argc argv) list.

Package

cl-getopt.

Source

cl-getopt.lisp.

Macro: with-foreign-longopts ((foreign-array long-only-list) options &body body)
Package

cl-getopt.

Source

cl-getopt.lisp.

Macro: with-foreign-shortopts (shortopts-binding options &body body)
Package

cl-getopt.

Source

cl-getopt.lisp.


Next: , Previous: , Up: Internals   [Contents][Index]

5.2.2 Ordinary functions

Function: ->optionstr (x)
Package

cl-getopt.

Source

cl-getopt.lisp.

Function: ->shortchar (x)
Package

cl-getopt.

Source

cl-getopt.lisp.

Function: c-getopt-long (argc argv shortopts longopts index)
Package

cl-getopt.

Source

cl-getopt.lisp.

Function: option-shortarg (option)
Package

cl-getopt.

Source

cl-getopt.lisp.

Function: options->shortargs (options)
Package

cl-getopt.

Source

cl-getopt.lisp.

Function: short-char (x)
Package

cl-getopt.

Source

cl-getopt.lisp.


5.2.3 Classes

Class: option
Package

cl-getopt.

Source

cl-getopt.lisp.

Direct superclasses
  • foreign-struct-type.
  • translatable-foreign-type.

Appendix A Indexes


Next: , Previous: , Up: Indexes   [Contents][Index]

A.1 Concepts


Next: , Previous: , Up: Indexes   [Contents][Index]

A.3 Variables