From 322867ab2322d9230955f44390b636492bba8666 Mon Sep 17 00:00:00 2001 From: Sibi Prabakaran Date: Sun, 6 Aug 2023 22:18:12 +0530 Subject: [PATCH 1/2] justl-exec-recipe-in-dir now prompts for args when needed Fixes https://github.com/psibi/justl.el/issues/30 --- justl.el | 16 +++++++++++++--- test/justl-test.el | 24 ++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 3 deletions(-) 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) From 43c7b8a5270259062275f5195f115d575526a250 Mon Sep 17 00:00:00 2001 From: Sibi Prabakaran Date: Sun, 6 Aug 2023 22:19:37 +0530 Subject: [PATCH 2/2] Update changelog --- Changelog.org | 5 +++++ 1 file changed, 5 insertions(+) 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.