The cl-getopt Reference Manual

Table of Contents

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

The cl-getopt Reference Manual

This is the cl-getopt Reference Manual, generated automatically by Declt version 3.0 "Montgomery Scott" on Sun May 15 03:49:39 2022 GMT+0.


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

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.


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

2 Systems

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


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

2.1 cl-getopt

Author

Gary Hollis

License

Public Domain

Description

CFFI wrapper to the libc getopt_long function

Defsystem Dependency

cffi-grovel

Dependency

cffi

Source

cl-getopt.asd (file)

Components

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

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 files   [Contents][Index]

3.1.1 cl-getopt.asd

Location

cl-getopt.asd

Systems

cl-getopt (system)


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

3.1.2 cl-getopt/package.lisp

Parent

cl-getopt (system)

Location

package.lisp

Packages

cl-getopt


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

3.1.3 cl-getopt/grovel.lisp

Dependency

package.lisp (file)

Parent

cl-getopt (system)

Location

grovel.lisp


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

3.1.4 cl-getopt/cl-getopt.lisp

Dependency

grovel.lisp (file)

Parent

cl-getopt (system)

Location

cl-getopt.lisp

Exported Definitions
Internal Definitions

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

4 Packages

Packages are listed by definition order.


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

4.1 cl-getopt

Source

package.lisp (file)

Use List
Exported Definitions
Internal Definitions

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

5 Definitions

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


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

5.1 Exported definitions


Previous: , Up: Exported definitions   [Contents][Index]

5.1.1 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 (file)

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 (file)


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

5.2 Internal definitions


Next: , Previous: , Up: Internal definitions   [Contents][Index]

5.2.1 Constants

Constant: +no-argument+
Package

cl-getopt

Source

/home/quickref/.cache/common-lisp/sbcl-1.5.8-linux-x64/home/quickref/quicklisp/dists/quicklisp/software/cl-getopt-20211209-git/grovel.processed-grovel-file

Constant: +optional-argument+
Package

cl-getopt

Source

/home/quickref/.cache/common-lisp/sbcl-1.5.8-linux-x64/home/quickref/quicklisp/dists/quicklisp/software/cl-getopt-20211209-git/grovel.processed-grovel-file

Constant: +required-argument+
Package

cl-getopt

Source

/home/quickref/.cache/common-lisp/sbcl-1.5.8-linux-x64/home/quickref/quicklisp/dists/quicklisp/software/cl-getopt-20211209-git/grovel.processed-grovel-file


Next: , Previous: , Up: Internal definitions   [Contents][Index]

5.2.2 Symbol macros

Symbol Macro: +optarg+
Package

cl-getopt

Source

/home/quickref/.cache/common-lisp/sbcl-1.5.8-linux-x64/home/quickref/quicklisp/dists/quicklisp/software/cl-getopt-20211209-git/grovel.processed-grovel-file

Expansion

(cl-getopt::%var-accessor-+optarg+)

Symbol Macro: +opterr+
Package

cl-getopt

Source

/home/quickref/.cache/common-lisp/sbcl-1.5.8-linux-x64/home/quickref/quicklisp/dists/quicklisp/software/cl-getopt-20211209-git/grovel.processed-grovel-file

Expansion

(cl-getopt::%var-accessor-+opterr+)

Symbol Macro: +optind+
Package

cl-getopt

Source

/home/quickref/.cache/common-lisp/sbcl-1.5.8-linux-x64/home/quickref/quicklisp/dists/quicklisp/software/cl-getopt-20211209-git/grovel.processed-grovel-file

Expansion

(cl-getopt::%var-accessor-+optind+)

Symbol Macro: +optopt+
Package

cl-getopt

Source

/home/quickref/.cache/common-lisp/sbcl-1.5.8-linux-x64/home/quickref/quicklisp/dists/quicklisp/software/cl-getopt-20211209-git/grovel.processed-grovel-file

Expansion

(cl-getopt::%var-accessor-+optopt+)


Next: , Previous: , Up: Internal definitions   [Contents][Index]

5.2.3 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 (file)

Macro: with-foreign-longopts (FOREIGN-ARRAY LONG-ONLY-LIST) OPTIONS &body BODY
Package

cl-getopt

Source

cl-getopt.lisp (file)

Macro: with-foreign-shortopts SHORTOPTS-BINDING OPTIONS &body BODY
Package

cl-getopt

Source

cl-getopt.lisp (file)


Next: , Previous: , Up: Internal definitions   [Contents][Index]

5.2.4 Functions

Function: %var-accessor-+optarg+ ()
Function: (setf %var-accessor-+optarg+) VALUE
Package

cl-getopt

Source

/home/quickref/.cache/common-lisp/sbcl-1.5.8-linux-x64/home/quickref/quicklisp/dists/quicklisp/software/cl-getopt-20211209-git/grovel.processed-grovel-file

Function: %var-accessor-+opterr+ ()
Function: (setf %var-accessor-+opterr+) VALUE
Package

cl-getopt

Source

/home/quickref/.cache/common-lisp/sbcl-1.5.8-linux-x64/home/quickref/quicklisp/dists/quicklisp/software/cl-getopt-20211209-git/grovel.processed-grovel-file

Function: %var-accessor-+optind+ ()
Function: (setf %var-accessor-+optind+) VALUE
Package

cl-getopt

Source

/home/quickref/.cache/common-lisp/sbcl-1.5.8-linux-x64/home/quickref/quicklisp/dists/quicklisp/software/cl-getopt-20211209-git/grovel.processed-grovel-file

Function: %var-accessor-+optopt+ ()
Function: (setf %var-accessor-+optopt+) VALUE
Package

cl-getopt

Source

/home/quickref/.cache/common-lisp/sbcl-1.5.8-linux-x64/home/quickref/quicklisp/dists/quicklisp/software/cl-getopt-20211209-git/grovel.processed-grovel-file

Function: ->optionstr X
Package

cl-getopt

Source

cl-getopt.lisp (file)

Function: ->shortchar X
Package

cl-getopt

Source

cl-getopt.lisp (file)

Function: c-getopt-long ARGC ARGV SHORTOPTS LONGOPTS INDEX
Package

cl-getopt

Source

cl-getopt.lisp (file)

Function: option-shortarg OPTION
Package

cl-getopt

Source

cl-getopt.lisp (file)

Function: options->shortargs OPTIONS
Package

cl-getopt

Source

cl-getopt.lisp (file)

Function: short-char X
Package

cl-getopt

Source

cl-getopt.lisp (file)


Previous: , Up: Internal definitions   [Contents][Index]

5.2.5 Classes

Class: option ()
Package

cl-getopt

Source

cl-getopt.lisp (file)

Direct superclasses
  • translatable-foreign-type (class)
  • foreign-struct-type (class)

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

Appendix A Indexes


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

A.1 Concepts

Jump to:   C   F   L  
Index Entry  Section

C
cl-getopt.asd: The cl-getopt․asd file
cl-getopt/cl-getopt.lisp: The cl-getopt/cl-getopt․lisp file
cl-getopt/grovel.lisp: The cl-getopt/grovel․lisp file
cl-getopt/package.lisp: The cl-getopt/package․lisp file

F
File, Lisp, cl-getopt.asd: The cl-getopt․asd file
File, Lisp, cl-getopt/cl-getopt.lisp: The cl-getopt/cl-getopt․lisp file
File, Lisp, cl-getopt/grovel.lisp: The cl-getopt/grovel․lisp file
File, Lisp, cl-getopt/package.lisp: The cl-getopt/package․lisp file

L
Lisp File, cl-getopt.asd: The cl-getopt․asd file
Lisp File, cl-getopt/cl-getopt.lisp: The cl-getopt/cl-getopt․lisp file
Lisp File, cl-getopt/grovel.lisp: The cl-getopt/grovel․lisp file
Lisp File, cl-getopt/package.lisp: The cl-getopt/package․lisp file

Jump to:   C   F   L  

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

A.2 Functions

Jump to:   %   (   -  
C   F   G   M   O   S   W  
Index Entry  Section

%
%var-accessor-+optarg+: Internal functions
%var-accessor-+opterr+: Internal functions
%var-accessor-+optind+: Internal functions
%var-accessor-+optopt+: Internal functions

(
(setf %var-accessor-+optarg+): Internal functions
(setf %var-accessor-+opterr+): Internal functions
(setf %var-accessor-+optind+): Internal functions
(setf %var-accessor-+optopt+): Internal functions

-
->optionstr: Internal functions
->shortchar: Internal functions

C
c-getopt-long: Internal functions

F
Function, %var-accessor-+optarg+: Internal functions
Function, %var-accessor-+opterr+: Internal functions
Function, %var-accessor-+optind+: Internal functions
Function, %var-accessor-+optopt+: Internal functions
Function, (setf %var-accessor-+optarg+): Internal functions
Function, (setf %var-accessor-+opterr+): Internal functions
Function, (setf %var-accessor-+optind+): Internal functions
Function, (setf %var-accessor-+optopt+): Internal functions
Function, ->optionstr: Internal functions
Function, ->shortchar: Internal functions
Function, c-getopt-long: Internal functions
Function, getopt: Exported functions
Function, option-descriptions: Exported functions
Function, option-shortarg: Internal functions
Function, options->shortargs: Internal functions
Function, short-char: Internal functions

G
getopt: Exported functions

M
Macro, with-foreign-args: Internal macros
Macro, with-foreign-longopts: Internal macros
Macro, with-foreign-shortopts: Internal macros

O
option-descriptions: Exported functions
option-shortarg: Internal functions
options->shortargs: Internal functions

S
short-char: Internal functions

W
with-foreign-args: Internal macros
with-foreign-longopts: Internal macros
with-foreign-shortopts: Internal macros

Jump to:   %   (   -  
C   F   G   M   O   S   W  

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

A.3 Variables

Jump to:   +  
C   S  
Index Entry  Section

+
+no-argument+: Internal constants
+optarg+: Internal symbol macros
+opterr+: Internal symbol macros
+optind+: Internal symbol macros
+optional-argument+: Internal constants
+optopt+: Internal symbol macros
+required-argument+: Internal constants

C
Constant, +no-argument+: Internal constants
Constant, +optional-argument+: Internal constants
Constant, +required-argument+: Internal constants

S
Symbol Macro, +optarg+: Internal symbol macros
Symbol Macro, +opterr+: Internal symbol macros
Symbol Macro, +optind+: Internal symbol macros
Symbol Macro, +optopt+: Internal symbol macros

Jump to:   +  
C   S  

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

A.4 Data types

Jump to:   C   O   P   S  
Index Entry  Section

C
cl-getopt: The cl-getopt system
cl-getopt: The cl-getopt package
Class, option: Internal classes

O
option: Internal classes

P
Package, cl-getopt: The cl-getopt package

S
System, cl-getopt: The cl-getopt system

Jump to:   C   O   P   S