From 14aa1286439407e9273abd952522bc6e713bd660 Mon Sep 17 00:00:00 2001 From: Tom Willemsen Date: Thu, 21 Mar 2013 21:39:56 +0100 Subject: Extract parse-args from clark Keep functions nice and small. --- clark.lisp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'clark.lisp') diff --git a/clark.lisp b/clark.lisp index aa4ea35..b7bb4ff 100644 --- a/clark.lisp +++ b/clark.lisp @@ -45,6 +45,17 @@ The result contains the url and the name of the bookmark." (intern (concatenate 'string (string-upcase base) "-COMMAND") :org.ryuslash.clark)) +(defun parse-args (args) + "Parse command-line arguments ARGS. + +The executable name should already have been removed." + (let ((cmd-name (make-command-name (car args)))) + (if (fboundp cmd-name) + (funcall cmd-name (cdr args)) + (progn + (format t "Unknown command: ~A~%" (car args)) + (help-command nil))))) + (defun print-bookmark (bm) "Print information about bookmark BM. @@ -63,7 +74,6 @@ Connect to the database, parse command-line arguments, execute and then disconnect." (check-db "test2.db") (if (> (length args) 1) - (let* ((cmd-name (make-command-name (cadr args)))) - (when (fboundp cmd-name) (funcall cmd-name (cdr args)))) + (parse-args (cdr args)) (map nil #'print-bookmark (get-bookmarks))) (disconnect *db*)) -- cgit v1.2.3-54-g00ecf