Created
June 27, 2024 08:09
-
-
Save kijowski/e458539a27d917f5421546d9a42b8b4b to your computer and use it in GitHub Desktop.
Interactively execute Adonisjs command
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun execute-adonis-command() | |
"Interactively execute adonis command in projectile root" | |
(interactive) | |
(projectile-with-default-dir | |
(projectile-acquire-root) | |
(let* ((commands-string (shell-command-to-string "node --no-warnings ace list --json")) | |
(commands-json (json-parse-string commands-string :object-type 'alist)) | |
(commands-names (cl-loop for entry across commands-json | |
collect (let ((description (let-alist entry .description)) | |
(name (let-alist entry .commandName))) | |
(list name description)))) | |
(command (consult--read | |
commands-names | |
:prompt "Ace command: " | |
:require-match t | |
:category 'ace-command | |
:annotate | |
(lambda (cand) | |
(format " %s" (cadr (seq-find (lambda (item) (s-equals-p (car item) cand)) commands-names)))))) | |
(help-string (shell-command-to-string (concat "node --no-warnings ace " command " --help"))) | |
(full-command (read-string (s-trim-left (concat help-string "\n")) (concat command " ")))) | |
(projectile-run-shell-command-in-root (concat "node --no-warnings ace " full-command))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment