diff --git a/Changelog.org b/Changelog.org index 9429a75..15886fc 100644 --- a/Changelog.org +++ b/Changelog.org @@ -1,3 +1,8 @@ +* Unreleased + +- justl-exec-recipe-in-dir prompts for arguments when needed. Fixes + [[https://github.com/psibi/justl.el/issues/30][issue 30]]. + * 0.12 - Add unstable flag to transient. diff --git a/justl.el b/justl.el index 2f8bbd1..236d5fd 100644 --- a/justl.el +++ b/justl.el @@ -513,9 +513,19 @@ and output of process." (defun justl-exec-recipe-in-dir () "Populate and execute the selected recipe." (interactive) - (let* ((recipies (completing-read "Recipies: " (justl--get-recipies) - nil nil nil nil "default"))) - (justl--exec-without-justfile justl-executable (list recipies)))) + (let* ((recipe (completing-read "Recipies: " (justl--get-recipies) + nil nil nil nil "default")) + (justl-recipe (justl--get-recipe-from-file justl-justfile recipe)) + (recipe-has-args (justl--jrecipe-has-args-p justl-recipe))) + (if recipe-has-args + (let* ((cmd-args (justl-jrecipe-args justl-recipe)) + (user-args (mapcar (lambda (arg) (read-from-minibuffer + (format "Just arg for %s:" (justl-jarg-arg arg)) + (justl--util-maybe (justl-jarg-default arg) ""))) + cmd-args))) + (justl--exec-without-justfile justl-executable + (cons (justl-jrecipe-name justl-recipe) user-args))) + (justl--exec-without-justfile justl-executable (list recipe))))) (defun justl-exec-default-recipe () "Execute default recipe." diff --git a/test/justl-test.el b/test/justl-test.el index 47c29e0..589d779 100644 --- a/test/justl-test.el +++ b/test/justl-test.el @@ -251,6 +251,30 @@ (should (s-contains? "Available recipes:\n" buf-string)))) (kill-buffer justl--output-process-buffer)) +(ert-deftest justl--execute-interactive-recipe () + "Checks justl-exec-recipe-in-dir indirectly (success case)." + (justl--exec-without-justfile "just" (list "plan")) + (justl--wait-till-exit justl--output-process-buffer) + (with-current-buffer justl--output-process-buffer + (let ((buf-string (buffer-substring-no-properties (point-min) (point-max)))) + (should (s-contains? "planner" buf-string))))) + +(ert-deftest justl--execute-interactive-recipe-failure () + "Checks justl-exec-recipe-in-dir indrectly (failure case)." + (justl--exec-without-justfile "just" (list "plan_non_existent")) + (justl--wait-till-exit justl--output-process-buffer) + (with-current-buffer justl--output-process-buffer + (let ((buf-string (buffer-substring-no-properties (point-min) (point-max)))) + (should (s-contains? "exited abnormally" buf-string))))) + +(ert-deftest justl--execute-interactive-recipe-multiple-args () + "Checks justl-exec-recipe-in-dir indrectly (failure case)." + (justl--exec-without-justfile "just" (list "push2" "ver1" "ver2")) + (justl--wait-till-exit justl--output-process-buffer) + (with-current-buffer justl--output-process-buffer + (let ((buf-string (buffer-substring-no-properties (point-min) (point-max)))) + (should (s-contains? "ver1" buf-string))))) + ;; (ert "justl--**") (provide 'justl-test)