diff --git a/Changelog.org b/Changelog.org index 10c3daf..d73e923 100644 --- a/Changelog.org +++ b/Changelog.org @@ -7,6 +7,8 @@ buffer. - Bugfix: Use the buffer's last command for recompile, not the last one across all buffers. +- Support optional argument prompting in + ~justl-exec-recipe-in-dir~. Fixes [[https://github.com/psibi/justl.el/issues/41][issue 41]]. * 0.14 diff --git a/justl.el b/justl.el index 9334681..26c9ad9 100644 --- a/justl.el +++ b/justl.el @@ -494,7 +494,7 @@ They are returned as objects, as per the JSON output of \"just --dump\"." (recipe-name (completing-read "Recipes: " (mapcar 'justl--recipe-name recipes) nil t nil nil)) - (recipe (cdr (assoc recipe-name recipes)))) + (recipe (justl--find-recipes recipes recipe-name))) (justl--exec-without-justfile justl-executable (cons recipe-name @@ -646,6 +646,10 @@ is not executed." ('nil nil) (_ default))))) +(defun justl--find-recipes (recipes name) + "Return recipe from RECIPES matching NAME." + (seq-first (seq-filter (lambda (recipe) (string= (recipe-name recipe) name)) recipes))) + (defun justl-exec-recipe () "Execute just recipe." (interactive) diff --git a/test/justl-test.el b/test/justl-test.el index b7e487a..c132435 100644 --- a/test/justl-test.el +++ b/test/justl-test.el @@ -13,6 +13,11 @@ (list "default" "build-cmd" "plan" "push" "push2" "fail" "carriage-return" "color") (mapcar 'justl--recipe-name (justl--get-recipes "./justfile"))))) +(ert-deftest justl--finds-recipe-test () + (let* ((recipes (justl--get-recipes "./justfile")) + (recipe (justl--find-recipes recipes "default"))) + (should (string= (recipe-doc recipe) "List all recipes")))) + (ert-deftest justl--get-description-test () (let* ((recipes (justl--get-recipes "./justfile")) (recipe (seq-find (lambda (r) (string= "default" (justl--recipe-name r))) recipes)))