The cl-cli-parser Reference Manual

Table of Contents

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

The cl-cli-parser Reference Manual

This is the cl-cli-parser Reference Manual, version 0.1, generated automatically by Declt version 2.3 "Robert April" on Wed Mar 14 03:10:37 2018 GMT+0.


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

1 Systems

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


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

1.1 cli-parser

Author

Denis Bueno

License

Copyright (c) 2005

Description

A command-line argument parser. Mostly parses options of the same form that getopt parses

Version

0.1

Source

cli-parser.asd (file)

Component

cli-parser.lisp (file)


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

2 Files

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


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

2.1 Lisp


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

2.1.1 cli-parser.asd

Location

cli-parser.asd

Systems

cli-parser (system)


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

2.1.2 cli-parser/cli-parser.lisp

Parent

cli-parser (system)

Location

cli-parser.lisp

Packages

cli-parser

Exported Definitions
Internal Definitions

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

3 Packages

Packages are listed by definition order.


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

3.1 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.

Source

cli-parser.lisp (file)

Use List
Exported Definitions
Internal Definitions

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

4 Definitions

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


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

4.1 Exported definitions


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

4.1.1 Functions

Function: cli-formatted-options OPTION-LIST
Package

cli-parser

Source

cli-parser.lisp (file)

Function: cli-parse ARGS CLI-OPTS

See CLI-PARSE-HASH.

Package

cli-parser

Source

cli-parser.lisp (file)

Function: cli-parse-assoc ARGS CLI-OPTS

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)).

Package

cli-parser

Source

cli-parser.lisp (file)

Function: cli-parse-hash ARGS CLI-OPTS

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.

Package

cli-parser

Source

cli-parser.lisp (file)

Function: cli-usage COMMAND-NAME OPTIONS-LIST

Print the command line usage

Package

cli-parser

Source

cli-parser.lisp (file)


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

4.1.2 Generic functions

Generic Function: cli-option-abbr OBJECT
Generic Function: (setf cli-option-abbr) NEW-VALUE OBJECT
Package

cli-parser

Methods
Method: cli-option-abbr (CLI-OPTION cli-option)

automatically generated reader method

Source

cli-parser.lisp (file)

Method: (setf cli-option-abbr) NEW-VALUE (CLI-OPTION cli-option)

automatically generated writer method

Source

cli-parser.lisp (file)

Generic Function: cli-option-description OBJECT
Generic Function: (setf cli-option-description) NEW-VALUE OBJECT
Package

cli-parser

Methods
Method: cli-option-description (CLI-OPTION cli-option)

automatically generated reader method

Source

cli-parser.lisp (file)

Method: (setf cli-option-description) NEW-VALUE (CLI-OPTION cli-option)

automatically generated writer method

Source

cli-parser.lisp (file)

Generic Function: cli-option-example OBJECT
Generic Function: (setf cli-option-example) NEW-VALUE OBJECT
Package

cli-parser

Methods
Method: cli-option-example (CLI-OPTION cli-option)

automatically generated reader method

Source

cli-parser.lisp (file)

Method: (setf cli-option-example) NEW-VALUE (CLI-OPTION cli-option)

automatically generated writer method

Source

cli-parser.lisp (file)

Generic Function: cli-option-full OBJECT
Generic Function: (setf cli-option-full) NEW-VALUE OBJECT
Package

cli-parser

Methods
Method: cli-option-full (CLI-OPTION cli-option)

automatically generated reader method

Source

cli-parser.lisp (file)

Method: (setf cli-option-full) NEW-VALUE (CLI-OPTION cli-option)

automatically generated writer method

Source

cli-parser.lisp (file)

Generic Function: cli-option-requires-arguments OBJECT
Generic Function: (setf cli-option-requires-arguments) NEW-VALUE OBJECT
Package

cli-parser

Methods
Method: cli-option-requires-arguments (CLI-OPTION cli-option)

automatically generated reader method

Source

cli-parser.lisp (file)

Method: (setf cli-option-requires-arguments) NEW-VALUE (CLI-OPTION cli-option)

automatically generated writer method

Source

cli-parser.lisp (file)


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

4.1.3 Classes

Class: cli-option ()
Package

cli-parser

Source

cli-parser.lisp (file)

Direct superclasses

standard-object (class)

Direct methods
Direct slots
Slot: abbreviation
Type

(or null string)

Initargs

:abbr

Readers

cli-option-abbr (generic function)

Writers

(setf cli-option-abbr) (generic function)

Slot: longname
Type

string

Initargs

:full

Readers

cli-option-full (generic function)

Writers

(setf cli-option-full) (generic function)

Slot: argumentsp
Type

(member nil t :optional)

Initargs

:requires-arguments

Readers

cli-option-requires-arguments (generic function)

Writers

(setf cli-option-requires-arguments) (generic function)

Slot: description
Type

string

Initargs

:description

Initform

"default description."

Readers

cli-option-description (generic function)

Writers

(setf cli-option-description) (generic function)

Slot: example
Type

string

Initargs

:example

Readers

cli-option-example (generic function)

Writers

(setf cli-option-example) (generic function)


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

4.2 Internal definitions


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

4.2.1 Special variables

Special Variable: *double-dash*

Long option prefix.

Package

cli-parser

Source

cli-parser.lisp (file)

Special Variable: *for-example-text*

String used to display for example.

Package

cli-parser

Source

cli-parser.lisp (file)

Special Variable: *option-value-sep*

String used to separate option values.

Package

cli-parser

Source

cli-parser.lisp (file)

Special Variable: *single-dash*

Short option prefix.

Package

cli-parser

Source

cli-parser.lisp (file)


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

4.2.2 Macros

Macro: pprint-clos-class INSTANCE SLOTS STREAM &key INTER-SLOT-NEWLINE-STYLE INTRA-SLOT-NEWLINE-STYLE UNBOUND-MSG SLOT-VALUE-CALLBACK

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>>

Package

cli-parser

Source

cli-parser.lisp (file)


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

4.2.3 Functions

Function: abbr->full-opt-name OPT CLI-OPTS

Converts an abbreviated option (i.e. "o") to its corresponding full option name. Returns the argument if no conversion is performed.

Package

cli-parser

Source

cli-parser.lisp (file)

Function: abbr-opt-p OPT

Test whether opt is a short option of the form "-o[=val]"

Package

cli-parser

Source

cli-parser.lisp (file)

Function: cli-parse-assoc-aux ARGS RESULTS

Helper for cli-parse.

Package

cli-parser

Source

cli-parser.lisp (file)

Function: cli-parse-hash-aux ARGS CLI-OPTS
Package

cli-parser

Source

cli-parser.lisp (file)

Function: coalesce-options ARGS

Will convert a list of the form ("–option-name=val1[,]" "val2[,]" " ... "valn" ...) to a list of the form ("–option-name=val1 val2 val3" ...).

Package

cli-parser

Source

cli-parser.lisp (file)

Function: coalesce-options-aux ARGS RESULTS

Helper for coalesce-options.

Package

cli-parser

Source

cli-parser.lisp (file)

Function: end-opt-name OPT

Returns the index of the end of the option-name. For example, end-opt-name would return 6 for the option "–opt1=val1"

Package

cli-parser

Source

cli-parser.lisp (file)

Function: formatted-option-string OPTION
Package

cli-parser

Source

cli-parser.lisp (file)

Function: full-opt-p OPT

Test whether opt is a long option of the form "–opt[=val]"

Package

cli-parser

Source

cli-parser.lisp (file)

Function: opt-name OPT

Extract the name of an option: for example "opt1" is the name from "–opt1=val1". Will return the argument if it is neither.

Package

cli-parser

Source

cli-parser.lisp (file)

Function: opt-p OPT

Evaluates to true if opt is an abbreviated or a full option.

Package

cli-parser

Source

cli-parser.lisp (file)

Function: opt-values OPT

Extract the values of an option: for example "val1" is the value from "–opt1=val1". If no values are specified, this function returns nil.

Package

cli-parser

Source

cli-parser.lisp (file)

Function: st-closest-val STR VAL-SEPARATORS

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.

Package

cli-parser

Source

cli-parser.lisp (file)

Function: st-first-val STR VAL-SEPARATORS

Returns the first token by parsing str. Analagous to car, but for the string tokenizer, instead of for lists.

Package

cli-parser

Source

cli-parser.lisp (file)

Function: st-rest-of STR VAL-SEPARATORS

Returns the rest of the string, not including the first
token. Analagous to cdr, but for the string tokenizer, instead of for lists.

Package

cli-parser

Source

cli-parser.lisp (file)

Function: string-tokenize STR VAL-SEPARATORS &key INCLUDE-SEPARATORS

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.

Package

cli-parser

Source

cli-parser.lisp (file)

Function: string-tokenize-aux STR VAL-SEPARATORS VALS INCLUDE-SEPARATORS

Helper for string-tokenize.

Package

cli-parser

Source

cli-parser.lisp (file)

Function: to-full-opt-name ARGNAME CLI-OPTS

Convert an option name to the full one, if necessary. Change "o" to "outfile", for example.

Package

cli-parser

Source

cli-parser.lisp (file)

Function: to-full-opt-names CL-ARGS CLI-OPTS

Converts any abbreviated option list of command-line options to the full option name.

Package

cli-parser

Source

cli-parser.lisp (file)


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
cli-parser.asd: The cli-parser<dot>asd file
cli-parser/cli-parser.lisp: The cli-parser/cli-parser<dot>lisp file

F
File, Lisp, cli-parser.asd: The cli-parser<dot>asd file
File, Lisp, cli-parser/cli-parser.lisp: The cli-parser/cli-parser<dot>lisp file

L
Lisp File, cli-parser.asd: The cli-parser<dot>asd file
Lisp File, cli-parser/cli-parser.lisp: The cli-parser/cli-parser<dot>lisp file

Jump to:   C   F   L  

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

A.2 Functions

Jump to:   (  
A   C   E   F   G   M   O   P   S   T  
Index Entry  Section

(
(setf cli-option-abbr): Exported generic functions
(setf cli-option-abbr): Exported generic functions
(setf cli-option-description): Exported generic functions
(setf cli-option-description): Exported generic functions
(setf cli-option-example): Exported generic functions
(setf cli-option-example): Exported generic functions
(setf cli-option-full): Exported generic functions
(setf cli-option-full): Exported generic functions
(setf cli-option-requires-arguments): Exported generic functions
(setf cli-option-requires-arguments): Exported generic functions

A
abbr->full-opt-name: Internal functions
abbr-opt-p: Internal functions

C
cli-formatted-options: Exported functions
cli-option-abbr: Exported generic functions
cli-option-abbr: Exported generic functions
cli-option-description: Exported generic functions
cli-option-description: Exported generic functions
cli-option-example: Exported generic functions
cli-option-example: Exported generic functions
cli-option-full: Exported generic functions
cli-option-full: Exported generic functions
cli-option-requires-arguments: Exported generic functions
cli-option-requires-arguments: Exported generic functions
cli-parse: Exported functions
cli-parse-assoc: Exported functions
cli-parse-assoc-aux: Internal functions
cli-parse-hash: Exported functions
cli-parse-hash-aux: Internal functions
cli-usage: Exported functions
coalesce-options: Internal functions
coalesce-options-aux: Internal functions

E
end-opt-name: Internal functions

F
formatted-option-string: Internal functions
full-opt-p: Internal functions
Function, abbr->full-opt-name: Internal functions
Function, abbr-opt-p: Internal functions
Function, cli-formatted-options: Exported functions
Function, cli-parse: Exported functions
Function, cli-parse-assoc: Exported functions
Function, cli-parse-assoc-aux: Internal functions
Function, cli-parse-hash: Exported functions
Function, cli-parse-hash-aux: Internal functions
Function, cli-usage: Exported functions
Function, coalesce-options: Internal functions
Function, coalesce-options-aux: Internal functions
Function, end-opt-name: Internal functions
Function, formatted-option-string: Internal functions
Function, full-opt-p: Internal functions
Function, opt-name: Internal functions
Function, opt-p: Internal functions
Function, opt-values: Internal functions
Function, st-closest-val: Internal functions
Function, st-first-val: Internal functions
Function, st-rest-of: Internal functions
Function, string-tokenize: Internal functions
Function, string-tokenize-aux: Internal functions
Function, to-full-opt-name: Internal functions
Function, to-full-opt-names: Internal functions

G
Generic Function, (setf cli-option-abbr): Exported generic functions
Generic Function, (setf cli-option-description): Exported generic functions
Generic Function, (setf cli-option-example): Exported generic functions
Generic Function, (setf cli-option-full): Exported generic functions
Generic Function, (setf cli-option-requires-arguments): Exported generic functions
Generic Function, cli-option-abbr: Exported generic functions
Generic Function, cli-option-description: Exported generic functions
Generic Function, cli-option-example: Exported generic functions
Generic Function, cli-option-full: Exported generic functions
Generic Function, cli-option-requires-arguments: Exported generic functions

M
Macro, pprint-clos-class: Internal macros
Method, (setf cli-option-abbr): Exported generic functions
Method, (setf cli-option-description): Exported generic functions
Method, (setf cli-option-example): Exported generic functions
Method, (setf cli-option-full): Exported generic functions
Method, (setf cli-option-requires-arguments): Exported generic functions
Method, cli-option-abbr: Exported generic functions
Method, cli-option-description: Exported generic functions
Method, cli-option-example: Exported generic functions
Method, cli-option-full: Exported generic functions
Method, cli-option-requires-arguments: Exported generic functions

O
opt-name: Internal functions
opt-p: Internal functions
opt-values: Internal functions

P
pprint-clos-class: Internal macros

S
st-closest-val: Internal functions
st-first-val: Internal functions
st-rest-of: Internal functions
string-tokenize: Internal functions
string-tokenize-aux: Internal functions

T
to-full-opt-name: Internal functions
to-full-opt-names: Internal functions

Jump to:   (  
A   C   E   F   G   M   O   P   S   T  

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

A.3 Variables

Jump to:   *  
A   D   E   L   S  
Index Entry  Section

*
*double-dash*: Internal special variables
*for-example-text*: Internal special variables
*option-value-sep*: Internal special variables
*single-dash*: Internal special variables

A
abbreviation: Exported classes
argumentsp: Exported classes

D
description: Exported classes

E
example: Exported classes

L
longname: Exported classes

S
Slot, abbreviation: Exported classes
Slot, argumentsp: Exported classes
Slot, description: Exported classes
Slot, example: Exported classes
Slot, longname: Exported classes
Special Variable, *double-dash*: Internal special variables
Special Variable, *for-example-text*: Internal special variables
Special Variable, *option-value-sep*: Internal special variables
Special Variable, *single-dash*: Internal special variables

Jump to:   *  
A   D   E   L   S  

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

A.4 Data types

Jump to:   C   P   S  
Index Entry  Section

C
Class, cli-option: Exported classes
cli-option: Exported classes
cli-parser: The cli-parser system
cli-parser: The cli-parser package

P
Package, cli-parser: The cli-parser package

S
System, cli-parser: The cli-parser system

Jump to:   C   P   S