fix autocompletion for a remote incus call
This commit is contained in:
+12
-19
@@ -16,7 +16,7 @@
|
|||||||
"TRAMP integration for Incus."
|
"TRAMP integration for Incus."
|
||||||
:group 'tramp)
|
:group 'tramp)
|
||||||
|
|
||||||
(defcustom incus-tramp-incus-executable "incus"
|
(defcustom incus-tramp-incus-program "incus"
|
||||||
"Path to the Incus executable."
|
"Path to the Incus executable."
|
||||||
:type 'string
|
:type 'string
|
||||||
:group 'incus-tramp)
|
:group 'incus-tramp)
|
||||||
@@ -25,18 +25,11 @@
|
|||||||
(defconst incus-tramp-method "incus"
|
(defconst incus-tramp-method "incus"
|
||||||
"Tramp method name to connect to Incus containers.")
|
"Tramp method name to connect to Incus containers.")
|
||||||
|
|
||||||
;;;###autoload
|
(defun tramp-incus-completion-function (method)
|
||||||
(defun incus-tramp--completion-function ()
|
(tramp-skeleton-completion-function method
|
||||||
"List running containers available for connection.
|
(when-let* ((raw-list (shell-command-to-string
|
||||||
|
(concat program " list status=running --columns=n --format=csv")))
|
||||||
This function is used by `tramp-set-completion-function', please
|
(names (split-string raw-list "\n" 'omit)))
|
||||||
see its function help for a description of the format."
|
|
||||||
(interactive)
|
|
||||||
(tramp-skeleton-completion-function incus-tramp-method
|
|
||||||
(when-let* ((raw-list
|
|
||||||
(shell-command-to-string
|
|
||||||
(concat program " list --columns=n --format=csv status=running")))
|
|
||||||
(names (split-string raw-list "\n" 'omit)))
|
|
||||||
(mapcar (lambda (name) (list nil name)) names))))
|
(mapcar (lambda (name) (list nil name)) names))))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
@@ -45,16 +38,16 @@ see its function help for a description of the format."
|
|||||||
(with-eval-after-load 'tramp
|
(with-eval-after-load 'tramp
|
||||||
(add-to-list 'tramp-methods
|
(add-to-list 'tramp-methods
|
||||||
`(,incus-tramp-method
|
`(,incus-tramp-method
|
||||||
(tramp-login-program ,incus-tramp-incus-executable)
|
(tramp-login-program ,incus-tramp-incus-program)
|
||||||
(tramp-login-args (("exec") ("%h") ("--") ("%l")))
|
(tramp-login-args (("exec") ("%h") (,(format "--env TERM=%s" tramp-terminal-type)) ("--") ("%l")))
|
||||||
(tramp-direct-async (,tramp-default-remote-shell "-c"))
|
(tramp-direct-async (,tramp-default-remote-shell "-c"))
|
||||||
(tramp-remote-shell ,tramp-default-remote-shell)
|
(tramp-remote-shell ,tramp-default-remote-shell)
|
||||||
(tramp-remote-shell-login ("-l"))
|
(tramp-remote-shell-login ("-l"))
|
||||||
(tramp-remote-shell-args ("-i" "-c"))
|
(tramp-remote-shell-args ("-i" "-c"))
|
||||||
(tramp-completion-use-cache nil)))
|
(tramp-completion-use-cache nil)
|
||||||
|
(tramp-connection-timeout 60)))
|
||||||
(tramp-set-completion-function tramp-docker-method
|
(tramp-set-completion-function incus-tramp-method
|
||||||
(incus-tramp--completion-function))
|
`((tramp-incus-completion-function ,incus-tramp-method)))
|
||||||
(add-to-list 'tramp-completion-multi-hop-methods incus-tramp-method)))
|
(add-to-list 'tramp-completion-multi-hop-methods incus-tramp-method)))
|
||||||
|
|
||||||
(provide 'incus-tramp)
|
(provide 'incus-tramp)
|
||||||
|
|||||||
Reference in New Issue
Block a user