Skip to content

Instantly share code, notes, and snippets.

@kijowski
Created June 27, 2024 08:09
Show Gist options
  • Save kijowski/e458539a27d917f5421546d9a42b8b4b to your computer and use it in GitHub Desktop.
Save kijowski/e458539a27d917f5421546d9a42b8b4b to your computer and use it in GitHub Desktop.
Interactively execute Adonisjs command
(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