Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

justl-exec-recipe-in-dir now prompts for args when needed #35

Merged
merged 2 commits into from
Aug 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Changelog.org
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
16 changes: 13 additions & 3 deletions justl.el
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down
24 changes: 24 additions & 0 deletions test/justl-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down