From 8771fe26c64f99c37e53a4fa14bfd0c91c840c6e Mon Sep 17 00:00:00 2001 From: John Hamelink Date: Wed, 30 Aug 2023 19:25:03 +0100 Subject: [PATCH 1/2] Fix just executable argument positioning (before the recipe) This commit changes the justl parsing and exec functions so that arguments are ordered correctly when calling just: arguments which are destined for just the executable should be defined before the recipe, since the recipe can have its own arguments. --- justl.el | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/justl.el b/justl.el index 6fa3d77..071adb7 100644 --- a/justl.el +++ b/justl.el @@ -351,18 +351,17 @@ Logs the command run." (defun justl--parse (justfile) "Extract info about JUSTFILE as parsed JSON." - (let ((json (justl--exec-to-string-with-exit-code - justl-executable - (justl--justfile-argument justfile) - "--unstable" "--dump" "--dump-format=json")) + (let* ((base-args (append `(,justl-executable) + (transient-args 'justl-help-popup) + `(,(justl--justfile-argument justfile)))) + (json (apply 'justl--exec-to-string-with-exit-code + (append base-args '("--dump" "--dump-format=json")))) ;; Obtain the unsorted declaration order separately (unsorted-recipes (s-split " " (s-trim-right - (justl--exec-to-string-with-exit-code - justl-executable - (justl--justfile-argument justfile) - "--summary" "--unsorted")) + (apply 'justl--exec-to-string-with-exit-code + (append base-args '("--summary" "--unsorted")))) t))) (let ((parsed (json-parse-string json :null-object nil :false-object nil :array-type 'list :object-type 'alist))) (cl-flet ((unsorted-index (r) @@ -478,14 +477,15 @@ not executed." (eshell-buffer-name (format "justl - eshell - %s" (justl--recipe-name recipe))) (default-directory (f-dirname justl-justfile))) (eshell) - (insert (string-join - (cons - justl-executable - (cons (justl--recipe-name recipe) - (append (transient-args 'justl-help-popup) - (mapcar 'justl--arg-default - (justl--recipe-args recipe))))) - " ")) + + (let* ((recipe-name (justl--recipe-name recipe)) + (recipe-args (justl--recipe-args recipe)) + (transient-args (transient-args 'justl-help-popup)) + (args-list (cons justl-executable + (append transient-args + (list recipe-name) + (mapcar 'justl--arg-default recipe-args))))) + (insert (string-join args-list " "))) (unless no-send (eshell-send-input)))) From 5647baed3fed199d1cf669dc339040a73edc8057 Mon Sep 17 00:00:00 2001 From: John Hamelink Date: Tue, 12 Sep 2023 10:42:47 +0100 Subject: [PATCH 2/2] Add the --unstable flag back in, but dedup the args list If the user sets the --unstable flag in Transient, the args list would have --unstable twice, which causes just to throw an error. Instead, deduplicate the list. --- justl.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/justl.el b/justl.el index 071adb7..dde097e 100644 --- a/justl.el +++ b/justl.el @@ -355,7 +355,7 @@ Logs the command run." (transient-args 'justl-help-popup) `(,(justl--justfile-argument justfile)))) (json (apply 'justl--exec-to-string-with-exit-code - (append base-args '("--dump" "--dump-format=json")))) + (delete-dups (append base-args '("--unstable" "--dump" "--dump-format=json"))))) ;; Obtain the unsorted declaration order separately (unsorted-recipes (s-split " "