aboutsummaryrefslogtreecommitdiffstats
path: root/oni/home
diff options
context:
space:
mode:
authorGravatar Tom Willemse2025-02-20 15:07:12 -0800
committerGravatar Tom Willemse2025-03-05 09:54:08 -0800
commit26674298e28529f91d65af81f88c5c74190991c8 (patch)
tree204884f6f1da041453dbbc4f1fd1c5b2883a496c /oni/home
parentf98a66890027314be24b5e8db6120907c27a23c2 (diff)
downloadnew-dotfiles-26674298e28529f91d65af81f88c5c74190991c8.tar.gz
new-dotfiles-26674298e28529f91d65af81f88c5c74190991c8.zip
pop-os/emacs: Improve artisan transient
- Turn the test command into its own Transient. Allow it to pick the right brand to test. Add ‘--stop-on-failure’ argument.
Diffstat (limited to 'oni/home')
-rw-r--r--oni/home/config/pop-os/emacs.el54
1 files changed, 35 insertions, 19 deletions
diff --git a/oni/home/config/pop-os/emacs.el b/oni/home/config/pop-os/emacs.el
index 77360c7..1db27a0 100644
--- a/oni/home/config/pop-os/emacs.el
+++ b/oni/home/config/pop-os/emacs.el
@@ -36,15 +36,16 @@
("pci" "Install" artisan-punt-composer-install)]
["Artisan"
("pac" "Run Command" artisan-punt-run-command)
- ("pam" "Migrate" artisan-punt-migrate)
- ("pat" "Test" artisan-punt-test)]]
+ ("pam" "Migrate" artisan-punt-migrate)]]
["Chanced"
["Composer"
("cci" "Install" artisan-chanced-composer-install)]
["Artisan"
("cac" "Run Command" artisan-chanced-run-command)
- ("cam" "Migrate" artisan-chanced-migrate)
- ("cat" "Test" artisan-chanced-test)]])
+ ("cam" "Migrate" artisan-chanced-migrate)]]
+
+ ["Commands"
+ ("t" "Test" artisan-test-transient)])
(defun artisan-punt-composer-install ()
(interactive)
@@ -80,41 +81,56 @@
(let ((default-directory (expand-file-name "chanced" (project-root (project-current)))))
(async-shell-command "docker exec -it chanced-backend php artisan migrate")))
-(defun artisan-punt-test (pick)
- (interactive "P")
- (artisan--test-internal pick "punt" "chanced"))
+(transient-define-prefix artisan-test-transient ()
+ "Artisan Test."
+
+ ["Arguments & Switches"
+ ("-b" "Brand" "--brand=" :choices ("chanced" "punt"))
+ ("-f" "Stop on failure" "--stop-on-failure")
+ ("-p" "Pick test" "--pick")]
+
+ ["Commands"
+ ("t" "Test" artisan-chanced-test)])
-(defun artisan-chanced-test (pick)
- (interactive "P")
- (artisan--test-internal pick "chanced" "punt"))
+(defun artisan-chanced-test (&optional args)
+ (interactive (list (transient-args transient-current-command)))
+ (let ((pick (transient-arg-value "--pick" args))
+ (fail (transient-arg-value "--stop-on-failure" args))
+ (brand (transient-arg-value "--brand=" args)))
+ (artisan--test-internal pick (or brand "chanced") "punt" fail)))
-(defvar artisan--test-last-command nil
+(defvar artisan--test-last-file nil
"The last testing commnand that was run in the test buffer.
This variable should always be buffer local and only set in test
buffers.")
-(make-variable-buffer-local 'artisan--test-last-command)
+(make-variable-buffer-local 'artisan--test-last-file)
-(defun artisan--test-internal (pick name ignore)
+(defun artisan--test-internal (pick name ignore fail)
(let* ((default-directory (expand-file-name name (project-root (project-current))))
(buffer-name (format "*%s Tests*" (capitalize name)))
(buffer (get-buffer-create buffer-name))
(files (cons '("all" . "")
(mapcar (lambda (dir) (cons (file-name-nondirectory dir) dir))
(directory-files-recursively "../" (rx "Test.php") nil (lambda (subdir) (not (or (string-suffix-p "vendor" subdir) (string-suffix-p ignore subdir))))))))
+ (file (or (and (not pick)
+ (with-current-buffer buffer
+ artisan--test-last-file))
+ (map-elt files (completing-read "File: " files nil t))))
(command (with-current-buffer buffer
- (or (and (not pick) artisan--test-last-command)
- (format "../../chanced-scripts/test %s %s"
- name (map-elt files (completing-read "File: " files nil t))))))
+ (format "../../chanced-scripts/test %s %s %s"
+ name
+ (if fail "--stop-on-failure" "")
+ file)) )
(compilation-scroll-output t))
(cl-letf (((symbol-function 'compilation-buffer-name)
- (lambda (&rest args) buffer-name)))
+ (lambda (&rest _) buffer-name)))
(compile command))
(with-current-buffer buffer
- (setq artisan--test-last-command command)
+ (setq artisan--test-last-file file)
(local-set-key (kbd "g")
(lambda ()
(interactive)
- (artisan--test-internal nil name ignore)))
+ (artisan--test-internal nil name ignore fail)))
(local-set-key (kbd "q") #'bury-buffer)
(local-set-key (kbd "s") (lambda () (interactive) (interrupt-process))))))