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

Ability to execute default recipe #29

Merged
merged 3 commits into from
Dec 22, 2022
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
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