1 ;;; simple.lisp --- Basic usage demonstration program
3 ;; Copyright (C) 2010, 2011, 2012 Didier Verna.
5 ;; Author: Didier Verna <didier@lrde.epita.fr>
6 ;; Maintainer: Didier Verna <didier@lrde.epita.fr>
8 ;; This file is part of Clon.
10 ;; Permission to use, copy, modify, and distribute this software for any
11 ;; purpose with or without fee is hereby granted, provided that the above
12 ;; copyright notice and this permission notice appear in all copies.
14 ;; THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
15 ;; WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
16 ;; MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
17 ;; ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
18 ;; WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
19 ;; ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
20 ;; OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
25 ;; Contents management by FCM version 0.1.
27 ;; This demonstration program shows how to define your application's
28 ;; command-line syntax, initialize the library, retrieve option values and
29 ;; generate help strings.
31 ;; #### NOTE: some trickery is needed below in order to make this code
32 ;; ECL-compliant, due to ECL's specific way of generating executables. This
34 ;; - setting *load-verbose* to nil,
35 ;; - passing a nil :verbose flag to asdf:load-system,
36 ;; - wrapping nickname-package in an eval-when form.
37 ;; None of these tweaks are needed for the other compilers.
44 (setq *load-verbose
* nil
)
48 #-
(or sbcl cmu ccl ecl allegro
49 (and lispworks
(not lispworks-personal-edition
)))
50 '(#p
"/usr/local/share/common-lisp/source/asdf/asdf.lisp"))
52 (asdf:load-system
:com.dvlsoft.clon
:verbose nil
)
54 (eval-when (:execute
:load-toplevel
:compile-toplevel
)
55 (com.dvlsoft.clon
:nickname-package
))
57 (clon:defsynopsis
(:postfix
"FILES...")
59 "Demonstration of Clon (use --clon-help for built-in options).")
60 (group (:header
"Flags (non valued options):")
61 (flag :short-name
"h" :long-name
"help"
62 :description
"Print this help and exit."))
63 (group (:header
"Built-in valued option types:")
64 (group (:header
"String options:")
65 (stropt :short-name
"n" :long-name
"name"
66 :description
"Set your name to NAME."
67 :argument-name
"NAME"))
68 (group (:header
"Lisp objects:")
69 (lispobj :short-name
"e" :long-name
"eval"
70 :description
"Evaluate EXPR."
71 :argument-name
"EXPR"))
72 (group (:header
"Enumerations:")
73 (enum :long-name
"copyright"
74 :description
"Set the copyright to LICENSE.
75 Possible values are: none, gpl, lppl, bsd or mit."
76 :argument-name
"LICENSE"
77 :argument-type
:optional
78 :enum
'(:none
:gpl
:lppl
:bsd
:mit
)
80 :default-value
:none
))
81 (group (:header
"Path options:")
82 (path :long-name
"tmpdir"
83 :description
"Set the temporary directory to DIR."
86 :default-value
#p
"/tmp/")
87 (path :short-name
"o" :long-name
"output"
88 :description
"Output to FILE."
91 :default-value
#p
"a.out")
93 :description
"Set the include search path to SEARCH-PATH.
94 SEARCH-PATH is a colon-separated list of directories. Use an empty argument to
95 remove all search paths."
96 :argument-name
"SEARCH-PATH"
98 :default-value
'(#p
"/usr/local/share/" #p
"/usr/share/")))
99 (group (:header
"Switches:")
100 (switch :short-name
"d" :long-name
"debug"
101 :description
"Turn debugging on or off."
102 :argument-style
:on
/off
104 (group (:header
"Extended switches:")
105 (xswitch :short-name
"c" :long-name
"connect"
106 :description
"Connect to server.
107 Possible values are yes, no or try. If try, no errors are reported."
111 "Entry point for the standalone application."
113 (cond ((clon:getopt
:short-name
"h")
116 (format t
"Program name: ~A~%~%" (clon:progname
))
117 (format t
"Options:")
118 (clon:do-cmdline-options
(option name value source
)
119 (print (list option name value source
)))
121 (format t
"Remainder: ~A~%" (clon:remainder
))))
124 (clon:dump
"simple" main
)
127 ;;; simple.lisp ends here