[cl-cli-parser-cvs] CVS update: cl-cli-parser/unit-test.lisp cl-cli-parser/cli-parser.lisp cl-cli-parser/ChangeLog
Denis Bueno
dbueno at common-lisp.net
Sat Mar 19 23:08:39 UTC 2005
Update of /project/cl-cli-parser/cvsroot/cl-cli-parser
In directory common-lisp.net:/tmp/cvs-serv10121
Modified Files:
unit-test.lisp cli-parser.lisp ChangeLog
Log Message:
see changelog.
Date: Sun Mar 20 00:08:37 2005
Author: dbueno
Index: cl-cli-parser/unit-test.lisp
diff -u cl-cli-parser/unit-test.lisp:1.2 cl-cli-parser/unit-test.lisp:1.3
--- cl-cli-parser/unit-test.lisp:1.2 Sat Mar 19 23:17:32 2005
+++ cl-cli-parser/unit-test.lisp Sun Mar 20 00:08:37 2005
@@ -34,5 +34,5 @@
(defun report-result (result form)
"Report the results of a single test case. Called by `check'."
- (format t "~:[FAIL~;pass~] ... ~a: ~a~%" result *test-name* form)
+ (format t "~:[FAIL~;pass~] ... ~a: ~w~%" result *test-name* form)
result)
Index: cl-cli-parser/cli-parser.lisp
diff -u cl-cli-parser/cli-parser.lisp:1.2 cl-cli-parser/cli-parser.lisp:1.3
--- cl-cli-parser/cli-parser.lisp:1.2 Sat Mar 19 21:07:00 2005
+++ cl-cli-parser/cli-parser.lisp Sun Mar 20 00:08:37 2005
@@ -1,4 +1,4 @@
-;;;; $Id: cli-parser.lisp,v 1.2 2005/03/19 20:07:00 dbueno Exp $
+;;;; $Id: cli-parser.lisp,v 1.3 2005/03/19 23:08:37 dbueno Exp $
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; Denis Bueno
;;;;
@@ -62,17 +62,17 @@
#:make-cli-option)
(:documentation
"Used for command-line-interface parsing, in the same tradition
-as getopt, but, a bit more convenient. The three exported main
-functions are:
+as getopt, but, a bit more convenient. The three main functions
+are:
-CLI-PARSE
-CLI-PARSE-HASH
-CLI-PARSE-ASSOC
+* CLI-PARSE
+* CLI-PARSE-HASH
+* CLI-PARSE-ASSOC
-cli-parse actually just calls cli-parse-hash, which will parse a
+CLI-PARSE actually just calls CLI-PARSE-HASH, which will parse a
list of command-line arguments against a list of cli-option
-objects. cli-parse-assoc, instead of returning a hash table of
-results like cli-parse-hash does, returns an assoc list of
+objects. CLI-PARSE-ASSOC, instead of returning a hash table of
+results like CLI-PARSE-HASH does, returns an assoc list of
results.
The idea is that you create a bunch of cli-option instances (via
@@ -87,34 +87,21 @@
(in-package :cli-parser)
-(defstruct cli-option
- (abbr nil :type (or string null))
- (full "" :type string)
- (requires-arguments nil :type boolean)
- (description "" :type string)
- (example "" :type string))
-
-(setf (documentation 'cli-option-abbr 'function)
- "Abbreviation for this command-line option."
- (documentation 'cli-option-full 'function)
- "The full name of this command-line option."
- (documentation 'cli-option-requires-arguments 'function)
- "Whether this command-line option requires arguments."
- (documentation 'cli-option-description 'function)
- "A sentence of description of this command-line option."
- (documentation 'cli-option-example 'function)
- "An example of the usage of this command-line option."
- (documentation 'cli-option-p 'function)
- "Test whether the argument is a cli-option.")
-
-;; (defclass cli-option ()
-;; ((abbreviation :initarg :abbr :accessor cli-option-abbr)
-;; (longname :initarg :long :accessor cli-option-long)
-;; (argumentsp :initform nil
-;; :initarg :argumentsp :accessor cli-option-argumentsp)
-;; (description :initform "Default description."
-;; :initarg :description :accesssor cli-option-description)
-;; (example :initarg :example :accessor cli-option-example)))
+;;; TODO: decide what to do if see an option like -cookycrisp: continuable
+;;; error/condition restart, ignore?
+
+(defclass cli-option ()
+ ((abbreviation :initarg :abbr :accessor cli-option-abbr)
+ (longname :initarg :full :accessor cli-option-full)
+ (argumentsp :initform nil
+ :initarg :requires-arguments
+ :accessor cli-option-requires-arguments)
+ (description :initform "Default description."
+ :initarg :description :accessor cli-option-description)
+ (example :initarg :example :accessor cli-option-example)))
+
+(defun make-cli-option (&rest initargs)
+ (apply #'make-instance 'cli-option initargs))
(defvar *single-dash* #\-
"Short option prefix.")
@@ -144,7 +131,8 @@
and you give \"--opt1=value1\" and \"-n\" to cli-parse-assoc, it
returns and assoc-list of the form ((\"opt1\" (\"value1\"
\"value2\")) (\"n\" nil))."
- (to-full-opt-names (cli-parse-assoc-aux (coalesce-options args) nil) cli-opts))
+ (to-full-opt-names (cli-parse-assoc-aux (coalesce-options args) nil)
+ cli-opts))
(defun cli-parse-assoc-aux (args results)
"Helper for cli-parse."
(cond ((endp args) (reverse results))
Index: cl-cli-parser/ChangeLog
diff -u cl-cli-parser/ChangeLog:1.1 cl-cli-parser/ChangeLog:1.2
--- cl-cli-parser/ChangeLog:1.1 Sat Mar 19 21:07:15 2005
+++ cl-cli-parser/ChangeLog Sun Mar 20 00:08:37 2005
@@ -1,5 +1,11 @@
2005-03-19 Denis Bueno <Denis.Bueno at gtri.gatech.edu>
+ * cli-parser.lisp (Global): Using CLOS classes instead of structs
+ now.
+
+ * unit-test.lisp: Unit testing framework (Seibel's).
+ (report-result): Write forms literally, not aesthetically.
+
* cli-parser-test.lisp: Unit test added.
* cli-parser.lisp: Stubbed out the class to replace the CLI-OPTION
More information about the Cl-cli-parser-cvs
mailing list