Skip to content

Commit

Permalink
Merge pull request #29 from psibi/default-recipe
Browse files Browse the repository at this point in the history
Ability to execute default recipe
  • Loading branch information
psibi authored Dec 22, 2022
2 parents 4dc372c + 6f6c133 commit a22c5ca
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
fail-fast: false
matrix:
emacs_version:
- 28.1
- 28.2
- 27.2
- 26.3
ignore_warnings:
Expand All @@ -24,7 +24,7 @@ jobs:
- uses: actions/checkout@v2
- uses: extractions/setup-just@v1
with:
just-version: 1.0.0
just-version: 1.8.0
- uses: purcell/setup-emacs@master
with:
version: ${{ matrix.emacs_version }}
Expand Down
2 changes: 2 additions & 0 deletions README.org
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ Alternatively if you want to just execute a recipe quickly, call
M-x justl-exec-recipe-in-dir
#+end_example

To execute default recipe, call *justl-exec-default-recipe*

* Shortcuts

On the just screen, place your cursor on a recipe:
Expand Down
10 changes: 9 additions & 1 deletion justl.el
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
;;
;; M-x justl-exec-recipe-in-dir
;;
;; To execute default recipe, call justl-exec-default-recipe
;;
;; Shortcuts:
;;
;; On the just screen, place your cursor on a recipe
Expand Down Expand Up @@ -472,7 +474,8 @@ and output of process."

(defun justl--justfile-from-arg (arg)
"Return justfile filepath from ARG."
(car (cdr (s-split "--justfile=" arg))))
(when arg
(car (cdr (s-split "--justfile=" arg)))))

(defun justl--get-recipies-with-desc (justfile)
"Return all the recipies in JUSTFILE with description."
Expand Down Expand Up @@ -506,6 +509,11 @@ and output of process."
nil nil nil nil "default")))
(justl--exec-without-justfile justl-executable (list recipies))))

(defun justl-exec-default-recipe ()
"Execute default recipe."
(interactive)
(justl--exec-without-justfile justl-executable nil))

(defvar justl-mode-map
(let ((map (make-sparse-keymap)))
(define-key map (kbd "g") 'justl--refresh-buffer)
Expand Down
9 changes: 9 additions & 0 deletions test/justl-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,15 @@
(kill-buffer (justl--buffer-name))
(kill-buffer justl--output-process-buffer))

(ert-deftest justl--execute-default-recipe ()
"Checks that default recipe is printed."
(justl-exec-default-recipe)
(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? "Available recipes:\n" buf-string))))
(kill-buffer justl--output-process-buffer))

;; (ert "justl--**")

(provide 'justl-test)
Expand Down

0 comments on commit a22c5ca

Please sign in to comment.