1 ;;; group.lisp --- Group management
3 ;; Copyright (C) 2010, 2011 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.
30 (in-package :com.dvlsoft.clon
)
31 (in-readtable :com.dvlsoft.clon
)
34 ;; ==========================================================================
36 ;; ==========================================================================
38 (defclass group
(container)
39 ((header :documentation
"The group's header."
43 (:documentation
"The GROUP class.
44 This class groups other groups, options or strings together, effectively
45 implementing hierarchical program command-line."))
48 ;; ---------------------------
49 ;; Help specification protocol
50 ;; ---------------------------
52 (defmethod help-spec ((group group
) &key
)
53 "Return GROUP's help specification."
57 ;; This calls the container's method.
58 (let ((items (call-next-method)))
60 (push 'items items
)))))
64 ;; ==========================================================================
65 ;; Group Instance Creation
66 ;; ==========================================================================
68 (defun make-group (&rest keys
&key header item hidden
)
70 (declare (ignore header item hidden
))
71 (apply #'make-instance
'group keys
))
73 (defmacro %defgroup
(internalp (&rest keys
&key header hidden
) &body forms
)
75 (declare (ignore header hidden
))
77 ,@(loop :for form
:in forms
81 (car (member (symbol-name (car form
))
86 (cond ((string= item-name
"GROUP")
90 "MAKE-~:[~;INTERNAL-~]~A"
91 internalp item-name
)))
93 (if (string= item-name
"GROUP")
94 (list* internalp
(cdr form
))
98 (defmacro defgroup
((&rest keys
&key header hidden
) &body forms
)
100 KEYS are initargs to MAKE-GROUP (currently, only :header).
101 Each form in FORMS will be treated as a new :item.
102 The CAR of each form is the name of the operation to perform: TEXT, GROUP, or
103 an option class name. The rest are the arguments to the MAKE-<OP> function or
105 (declare (ignore header hidden
))
106 `(%defgroup nil
,keys
,@forms
))
109 ;;; group.lisp ends here