Hide command detail

Hide the fact that a command is just of the form NAME-command by
abstracting it away into a macro.
This commit is contained in:
Tom Willemsen 2013-03-23 16:37:41 +01:00
parent c7f9d27638
commit fdce2ed81c

View file

@ -30,6 +30,10 @@
(defvar *max-command-name-length* 0 (defvar *max-command-name-length* 0
"Lenght of the longest command name.") "Lenght of the longest command name.")
(defmacro call-command (name &rest args)
(let ((command-name (make-command-name (symbol-name name))))
`(,command-name ,@args)))
(defmacro defcommand (name sdoc ldoc &body body) (defmacro defcommand (name sdoc ldoc &body body)
"Define a new command usable on the command-line." "Define a new command usable on the command-line."
(let* ((sname (symbol-name name)) (let* ((sname (symbol-name name))
@ -140,7 +144,7 @@ The executable name should already have been removed."
(funcall cmd-name (cdr args)) (funcall cmd-name (cdr args))
(progn (progn
(format t "Unknown command: ~A~%" (car args)) (format t "Unknown command: ~A~%" (car args))
(help-command nil))))) (call-command help nil)))))
(defun print-bookmark (bm) (defun print-bookmark (bm)
"Print information about bookmark BM. "Print information about bookmark BM.
@ -187,7 +191,7 @@ otherwise."
((null ldoc) (format t "Unkown command: ~A~%" (car args))) ((null ldoc) (format t "Unkown command: ~A~%" (car args)))
((and (symbolp ldoc) (fboundp ldoc)) (funcall ldoc)) ((and (symbolp ldoc) (fboundp ldoc)) (funcall ldoc))
(t (format t "~A~%" ldoc)))) (t (format t "~A~%" ldoc))))
(help-command '("help")))) (call-command help '("help"))))
(defcommand search (defcommand search
"Search through bookmarks." "Search through bookmarks."