Demo renamings.
[clon.git] / demos / simple.lisp
blob0fa911b445f441f84d6989de86a4e0645cf9e9c5
1 ;;; demo.lisp --- Demonstration program
3 ;; Copyright (C) 2010 Didier Verna
5 ;; Author: Didier Verna <didier@lrde.epita.fr>
6 ;; Maintainer: Didier Verna <didier@lrde.epita.fr>
7 ;; Created: Fri Aug 1 14:45:48 2008
8 ;; Last Revision: Sat Jun 12 17:59:07 2010
10 ;; This file is part of Clon.
12 ;; Clon is free software; you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License version 3,
14 ;; as published by the Free Software Foundation.
16 ;; Clon is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with this program; if not, write to the Free Software
23 ;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 ;;; Commentary:
28 ;; Contents management by FCM version 0.1.
31 ;;; Code:
33 (in-package :cl-user)
35 (require :asdf)
36 #-asdf2 (setf asdf:*central-registry*
37 (list* #p"../"
38 (merge-pathnames "share/common-lisp/systems/"
39 (user-homedir-pathname))
40 #p"/usr/local/share/common-lisp/systems/"
41 #p"/usr/share/common-lisp/systems/"
42 asdf:*central-registry*))
44 #-asdf2 (ignore-errors (asdf:operate 'asdf:load-op :asdf-binary-locations))
46 (asdf:operate 'asdf:load-op :com.dvlsoft.clon)
47 (rename-package :com.dvlsoft.clon
48 (package-name :com.dvlsoft.clon)
49 (adjoin :clon (package-nicknames :com.dvlsoft.clon)
50 :test #'string-equal))
52 (clon:defsynopsis (:postfix "FILES...")
53 (text :contents
54 "Demonstration of Clon (use --clon-help for built-in options).")
55 (group (:header "Flags (non valued options):")
56 (flag :short-name "h" :long-name "help"
57 :description "Print this help and exit."))
58 (group (:header "Built-in valued option types:")
59 (group (:header "String options:")
60 (stropt :short-name "n" :long-name "name"
61 :description "Set your name to NAME."
62 :argument-name "NAME"))
63 (group (:header "Lisp objects:")
64 (lispobj :short-name "e" :long-name "eval"
65 :description "Evaluate EXPR."
66 :argument-name "EXPR"))
67 (group (:header "Enumerations:")
68 (enum :long-name "copyright"
69 :description "Set the copyright to LICENSE.
70 Possible values are: none, gpl, lppl, bsd or mit."
71 :argument-name "LICENSE"
72 :argument-type :optional
73 :enum '(:none :gpl :lppl :bsd :mit)
74 :fallback-value :gpl
75 :default-value :none))
76 (group (:header "Path options:")
77 (path :long-name "tmpdir"
78 :description "Set the temporary directory to DIR."
79 :argument-name "DIR"
80 :type :directory
81 :default-value #p"/tmp/")
82 (path :short-name "o" :long-name "output"
83 :description "Output to FILE."
84 :argument-name "FILE"
85 :type :file
86 :default-value #p"a.out")
87 (path :short-name "I"
88 :description "Set the include search path to SEARCH-PATH.
89 SEARCH-PATH is a colon-separated list of directories. Use an empty argument to
90 remove all search paths."
91 :argument-name "SEARCH-PATH"
92 :type :directory-list
93 :default-value '(#p"/usr/local/share/" #p"/usr/share/")))
94 (group (:header "Switches:")
95 (switch :short-name "d" :long-name "debug"
96 :description "Turn debugging on or off."
97 :argument-style :on/off
98 :env-var "DEBUG"))
99 (group (:header "Extended switches:")
100 (xswitch :short-name "c" :long-name "connect"
101 :description "Connect to server.
102 Possible values are yes, no or try. If try, no errors are reported."
103 :enum '(:try)))))
105 (defun main ()
106 "Entry point for the standalone application."
107 (clon:make-context)
108 (cond ((clon:getopt :short-name "h")
109 (clon:help))
111 (format t "Program name: ~A~%~%" (clon:progname))
112 (format t "Options:")
113 (clon:do-cmdline-options (option name value source)
114 (print (list option name value source)))
115 (terpri)
116 (format t "Remainder: ~A~%" (clon:remainder))))
117 (clon:exit))
119 ;; #### PORTME.
120 (save-lisp-and-die "simple"
121 :toplevel #'main :executable t :save-runtime-options t)
124 ;;; demo.lisp ends here