From 3b3ebf8e31910ca81a4107b2b2394d1a0a172778 Mon Sep 17 00:00:00 2001 From: Grant Horner Date: Mon, 5 Jan 2026 14:42:54 -0500 Subject: [PATCH] can refresh data via command line --- main.lisp | 14 ++++++++------ utils.lisp | 2 +- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/main.lisp b/main.lisp index 24ed019..2816c5a 100644 --- a/main.lisp +++ b/main.lisp @@ -20,12 +20,12 @@ :when (string-equal current opt) :return next)) -(defun refresh-data (data-type) +(defun refresh-data (data-type maybe-file-path) (string-case data-type - ("drops" (refresh (make-drop-data-source))) - ("items" (refresh (make-item-data-source))) - ("mobs" (refresh (make-mob-data-source))) - ("spawns" (refresh (make-spawn-data-source))))) + ("drops" (refresh (maybe-pass #'make-drop-data-source maybe-file-path))) + ("items" (refresh (maybe-pass #'make-item-data-source maybe-file-path))) + ("mobs" (refresh (maybe-pass #'make-mob-data-source maybe-file-path))) + ("spawns" (refresh (maybe-pass #'make-spawn-data-source maybe-file-path))))) (defun main () (sb-ext:disable-debugger) @@ -34,7 +34,9 @@ (error "Simulated error!")) (when (find-string "--version" args) (print-version-information)) - (when-let ((arg (get-arg "refresh")))))) + (when-let ((arg (get-arg "refresh" args))) + (let ((maybe-file-path (get-arg "--output" args))) + (refresh-data arg maybe-file-path))))) (defun create-exe-and-die () (sb-ext:save-lisp-and-die diff --git a/utils.lisp b/utils.lisp index 06a0b2e..efbea11 100644 --- a/utils.lisp +++ b/utils.lisp @@ -36,7 +36,7 @@ (defun maybe-pass (func arg) "Pass ARG to FUNC if arg is not nil." - (if (fnil)arg + (if (equal arg nil) (funcall func arg) (funcall func)))