chiark
/
gitweb
/
~mdw
/
sod
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
src/utilities.lisp (compose): Handle the case of zero arguments.
[sod]
/
src
/
optparse.lisp
diff --git
a/src/optparse.lisp
b/src/optparse.lisp
index 74df161337a5163fca440528fc10ca259c5e56a0..5268cda728f33c69f7c8c7e65c7acbdeaaa059b0 100644
(file)
--- a/
src/optparse.lisp
+++ b/
src/optparse.lisp
@@
-83,9
+83,9
@@
(defun set-command-line-arguments ()
#+ecl (loop for i from 1
below (ext:argc)
collect (ext:argv i))))
#+ecl (loop for i from 1
below (ext:argc)
collect (ext:argv i))))
- (error "Unsupported Lisp
.
"))))))
+ (error "Unsupported Lisp"))))))
-
*program-name* (pathname-name (car *command-line*))))
+ *program-name* (pathname-name (car *command-line*))))
;;;--------------------------------------------------------------------------
;;; Fancy conditionals.
;;;--------------------------------------------------------------------------
;;; Fancy conditionals.
@@
-165,15
+165,19
@@
(defstruct (option
(opt-long-name o)
(opt-arg-optional-p o)
(opt-arg-name o)
(opt-long-name o)
(opt-arg-optional-p o)
(opt-arg-name o)
- (opt-documentation o)))))
- (:constructor %make-option)
+ (opt-%documentation o)))))
+ (:constructor %make-option
+ (&key long-name tag negated-tag short-name
+ arg-name arg-optional-p documentation
+ &aux (%documentation documentation)))
(:constructor make-option
(long-name short-name
&optional arg-name
&key (tag (intern (string-upcase long-name) :keyword))
negated-tag
arg-optional-p
(:constructor make-option
(long-name short-name
&optional arg-name
&key (tag (intern (string-upcase long-name) :keyword))
negated-tag
arg-optional-p
- doc (documentation doc))))
+ doc (documentation doc)
+ &aux (%documentation documentation))))
"Describes a command-line option. Slots:
LONG-NAME The option's long name. If this is null, the `option' is
"Describes a command-line option. Slots:
LONG-NAME The option's long name. If this is null, the `option' is
@@
-203,14
+207,15
@@
(defstruct (option
wrapped. If nil, the option is omitted from the help
text.
wrapped. If nil, the option is omitted from the help
text.
- Usually, one won't use
make-option, but use the option
macro instead."
+ Usually, one won't use
`make-option', but use the `option'
macro instead."
(long-name nil :type (or null string))
(tag nil :type t)
(negated-tag nil :type t)
(short-name nil :type (or null character))
(arg-name nil :type (or null string))
(arg-optional-p nil :type t)
(long-name nil :type (or null string))
(tag nil :type t)
(negated-tag nil :type t)
(short-name nil :type (or null character))
(arg-name nil :type (or null string))
(arg-optional-p nil :type t)
- (documentation nil :type (or null string)))
+ (%documentation nil :type (or null string)))
+(define-access-wrapper opt-documentation opt-%documentation)
(export '(option-parser option-parser-p make-option-parser
op-options op-non-option op-long-only-p op-numeric-p
(export '(option-parser option-parser-p make-option-parser
op-options op-non-option op-long-only-p op-numeric-p
@@
-225,6
+230,7
@@
(defstruct (option-parser
negated-numeric-p
long-only-p
&aux (args (cons nil argstmp))
negated-numeric-p
long-only-p
&aux (args (cons nil argstmp))
+ (%options options)
(next args)
(negated-p (or negated-numeric-p
(some #'opt-negated-tag
(next args)
(negated-p (or negated-numeric-p
(some #'opt-negated-tag
@@
-258,7
+264,7
@@
(defstruct (option-parser
still allowed, and may be cuddled as usual. The default is
nil."
(args nil :type list)
still allowed, and may be cuddled as usual. The default is
nil."
(args nil :type list)
- (options nil :type list)
+ (
%
options nil :type list)
(non-option :skip :type (or function (member :skip :stop :return)))
(next nil :type list)
(short-opt nil :type (or null string))
(non-option :skip :type (or function (member :skip :stop :return)))
(next nil :type list)
(short-opt nil :type (or null string))
@@
-268,6
+274,7
@@
(defstruct (option-parser
(numeric-p nil :type t)
(negated-numeric-p nil :type t)
(negated-p nil :type t))
(numeric-p nil :type t)
(negated-numeric-p nil :type t)
(negated-p nil :type t))
+(define-access-wrapper op-options op-%options)
(export 'option-parse-error)
(define-condition option-parse-error (error simple-condition)
(export 'option-parse-error)
(define-condition option-parse-error (error simple-condition)
@@
-889,11
+896,8
@@
(defmacro options (&rest optlist)
;;; Support stuff for help and usage messages.
(defun print-text (string
;;; Support stuff for help and usage messages.
(defun print-text (string
- &optional
- (stream *standard-output*)
- &key
- (start 0)
- (end nil))
+ &optional (stream *standard-output*)
+ &key (start 0) (end nil))
"Prints STRING to a pretty-printed STREAM, breaking it at whitespace and
newlines in the obvious way. Stuff between square brackets is not broken:
this makes usage messages work better."
"Prints STRING to a pretty-printed STREAM, breaking it at whitespace and
newlines in the obvious way. Stuff between square brackets is not broken:
this makes usage messages work better."