Function: tramp-container--completion-function

tramp-container--completion-function is an autoloaded and byte-compiled function defined in tramp-container.el.gz.

Signature

(tramp-container--completion-function METHOD)

Documentation

List running containers available for connection.

METHOD is the Tramp method to be used for "ps", either tramp-docker-method, tramp-dockercp-method, tramp-podman-method, or tramp-podmancp-method.

This function is used by tramp-set-completion-function, please see its function help for a description of the format.

Source Code

;; Defined in /usr/src/emacs/lisp/net/tramp-container.el.gz
;;;###tramp-autoload
(defun tramp-container--completion-function (method)
  "List running containers available for connection.
METHOD is the Tramp method to be used for \"ps\", either
`tramp-docker-method', `tramp-dockercp-method', `tramp-podman-method',
or `tramp-podmancp-method'.

This function is used by `tramp-set-completion-function', please
see its function help for a description of the format."
  (tramp-skeleton-completion-function method
    (when-let* ((raw-list
		 (shell-command-to-string
		  (concat program " ps --format '{{.ID}}\t{{.Names}}'")))
		(lines (split-string raw-list "\n" 'omit))
		(names
		 (tramp-compat-seq-keep
		  (lambda (line)
		    (when (string-match
			   (rx bol (group (1+ nonl))
			       "\t" (? (group (1+ nonl))) eol)
			   line)
		      (or (match-string 2 line) (match-string 1 line))))
		  lines)))
      (mapcar (lambda (name) (list nil name)) names))))