summaryrefslogtreecommitdiff
path: root/main.lisp
diff options
context:
space:
mode:
authorLogan Hunt <loganhunt@simponic.xyz>2022-05-31 10:31:37 -0700
committerLogan Hunt <loganhunt@simponic.xyz>2022-05-31 10:31:37 -0700
commite6fe31daef40bec71e962c502f3a17ff9fa59d31 (patch)
tree78943a3d34a5dab72e416d79e382898bc46d588f /main.lisp
parentf1a99a78d189319042cb767975bc2e5f4204f7bd (diff)
downloadlispruns-e6fe31daef40bec71e962c502f3a17ff9fa59d31.tar.gz
lispruns-e6fe31daef40bec71e962c502f3a17ff9fa59d31.zip
Add some more helpful error messages, fix CLI (some features still need implementation), add category selection for starting speedrun
Diffstat (limited to 'main.lisp')
-rw-r--r--main.lisp25
1 files changed, 13 insertions, 12 deletions
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)))))