80 columns formatting fixes.
[clon.git] / README
bloba3af254ed361b24791a4ea2079765c0797973d3e
1                                                              -*- outline -*-
3 * Introduction
5 In the Lisp family of languages, one of the key components is the so-called
6 REPL, the Read-Eval-Print Loop, which blends the runtime, compilation and
7 development phases together, allowing for a very high level of interaction
8 with the program. The importance of this paradigm explains why it is still
9 rare to find "standalone" applications written in Lisp: most Lisp application
10 clients are lispers themselves, and they prefer to live in the REPL.
12 On the other hand, many contemporary Common Lisp compilers provide ways of
13 creating standalone Common Lisp programs, using either shebang technology or
14 by directly dumping executables. This process is getting easier to achieve
15 every day. For instance, with SBCL, all it takes is one function call
16 (save-lisp-and-die) and one command-line option to the compiler (--script).
18 The (big) size of a Lisp image has been considered a showstopper in creating
19 standalone applications for a long time, but nowadays, it doesn't really
20 matter anymore (if you are not convinced, just figure out the average size of
21 an application bundle under Mac OS X). This, along with the fact that Common
22 Lisp compilers can generate very efficient code today, makes the perspective
23 of standalone Common Lisp applications very tempting again.
25 When it comes to preserving interaction with the user, one of the key
26 components in a standalone application is the handling of the command-line. 
27 Clon is a library designed to do just that.
30 * Overview
31 Clon provides traditional features one might expect from a command-line
32 options management library, but what makes it somewhat unique in its
33 conception is that it has been designed with both the application developer
34 and the application user in mind: many aspects of the command-line management
35 usually imposed by the program are in fact under the control of the
36 application user. The idea is that all Clon-enabled applications behave in a
37 uniform way, and that it is the user who gets to decide, not the developper. 
38 The most important features of Clon are listed below.
40 ** Command-Line Syntax
41 Clon imposes a particular yet flexible syntax for the command-line. Options
42 have short and/or long names, beginning with either one or two dashes. Options
43 may take an argument. In that case, the argument may be optional or mandatory. 
44 Option names may be abbreviated and one-character options may be grouped
45 together in a single call. There is an additional call syntax for Boolean or
46 Boolean-based options. Finally, the command-line may have a "postfix", that
47 is, a non-option part.
49 ** Option Types
50 Clon comes with a set of predefined option types, including "flags" (option
51 without arguments), "switches" (Boolean options), simple Lisp objects, simple
52 strings, enumerations, pathnames etc. Clon is also extensible: it is possible
53 to define new option types, either from scratch or by subclassing an existing
54 one.
56 ** Value Retrieval
57 The traditional approach to command-line analysis is to process it
58 sequentially, and Clon lets you do that. However, Clon also provides an
59 explicit retrieval mechanism by which you can directly request the value of a
60 specific option, regardless of its position, or even its presence on the
61 command-line. An option's value can be retrieved from different sources: a
62 command-line argument, a "fallback" value (for optional arguments), a default
63 value or an environment variable associated with the option. The retrieval
64 process is completely automated, hence removing this burden from the
65 developer's shoulders.
67 ** Error Management
68 Another cumbersome task already taken care of is error management. Clon
69 provides two built-in error management schemes, in case something is wrong on
70 the command-line. The simplest one is to quit the application with an
71 informative error message. The other one is to enter an interactive dialog
72 with the user, in which it is possible to fix the problem (correct a typo,
73 discard an option call, provide a missing argument or value etc.). A unique
74 feature of Clon is that the application user may choose his or her preferred
75 error management scheme.
77 ** Help String Contents
78 The "help string" is typically what you expect from the output of a --help
79 option. Maintaining an up-to-date help string is a very boring task, so Clon
80 completely automates this for you (another burden removed from the developer's
81 shoulders). However, the application programmer still has control over the
82 help string's contents, notably the order in which options are displayed, and
83 also by having the possibility of grouping options together and inserting
84 arbitrary text in the output.
86 ** Help String Format
87 Clon also completely automates the help string typesetting process. For
88 instance, it can automatically format the output for 80 columns, but it is
89 also aware of the tty geometry and will use it when appropriate. Clon also
90 supports help string "fontification" (or "highlighting") through ISO/IEC 6429
91 SGR escape sequences on tty's that support it. Another unique feature of Clon
92 is that the exact format and highlight specification for the help string is
93 under the control of the application user, via the notion of "theme". Clon
94 comes with a set of predefined themes (for instance, standard, with heavy
95 fontification, refcard for quick reference etc.) and application users can
96 define their own. As a matter of fact, a theme not only controls the format
97 and highlight of the help string, but also its contents.