From e6fe31daef40bec71e962c502f3a17ff9fa59d31 Mon Sep 17 00:00:00 2001 From: Logan Hunt Date: Tue, 31 May 2022 10:31:37 -0700 Subject: Add some more helpful error messages, fix CLI (some features still need implementation), add category selection for starting speedrun --- main.lisp | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'main.lisp') diff --git a/main.lisp b/main.lisp index 8d0d704..57a1d29 100644 --- a/main.lisp +++ b/main.lisp @@ -19,7 +19,9 @@ (let ((input (read-line))) (if (ignore-errors (funcall validator input)) input - (get-input prompt validator)))) + (progn + (format t "E: Invalid input. Try again.") + (get-input prompt validator))))) ;; Options is an alist with the prompt string as the car and the value as the cdr (defun select-option (options) @@ -49,8 +51,7 @@ (format t "That search came up with multiple results:") (select-option filtered))) (progn (format t "E: Could not find option that matched query.~%") - (select-option options)))))) - (format t "~%")) + (select-option options))))))) (defun main () (let ((choice (select-option '(("Help" . HELP) @@ -59,23 +60,23 @@ ("Start a speedrun" . START-SPEEDRUN) ("Statistics" . LIST-CATEGORIES) ("Exit" . EXIT))))) - (format t "~a~%" choice) (case choice ('HELP (mapcar #'(lambda (x) (format t "~a~%" x)) *lispruns-logo*)) ('IMPORT-CATEGORY - (import-category (get-input (format nil "Relative or absolute path to configuration file [~a]: " (uiop/os:getcwd)) 'probe-file))) + (import-category (get-input + (format nil "Relative or absolute path to configuration file [~a]: " + (uiop/os:getcwd)) + 'probe-file))) ('NEW-CATEGORY (format t "NEW CATEGORY~%")) ('START-SPEEDRUN - (speedrun-ui (car (mito:select-dao 'category)))) + (let* ((categories (mito:select-dao 'category)) + (category-alist (mapcar (lambda (category) `(,(category-name category) . ,category)) categories))) + (if categories + (speedrun-ui (select-option category-alist)) + (format t "E: There are no categories. Try creating one or importing one")))) ('EXIT (quit)))) (format t "~%") (main)) - - -;; (let ((options (opts:get-opts))) -;; (when-option (options :import) -;; (import-config (getf options :import))) -;; (run-ui (car (mito:select-dao 'category))))) -- cgit v1.2.3-70-g09d2