From: Eshel Yaron Date: Thu, 25 Jul 2024 08:16:10 +0000 (+0200) Subject: Integrate 'kubed-kubectl-command' with transient menus X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=0a067724ea34d8715f2e51ee1caaa80f33b2702c;p=emacs.git Integrate 'kubed-kubectl-command' with transient menus --- diff --git a/lisp/net/kubed-transient.el b/lisp/net/kubed-transient.el index d53b42223a1..6bd15655d9b 100644 --- a/lisp/net/kubed-transient.el +++ b/lisp/net/kubed-transient.el @@ -49,7 +49,11 @@ ("d" "deployment" kubed-transient-create-deployment) ("n" "namespace" kubed-create-namespace)] ["Actions" - ("c" "Create" kubed-create)]) + ("c" "Create" kubed-create) + ("!" "Command line" kubed-kubectl-command)] + (interactive) + (transient-setup 'kubed-transient-create nil nil + :scope '("create"))) ;;;###autoload (transient-define-prefix kubed-transient-create-deployment () @@ -67,7 +71,11 @@ ("--" "Command" "-- =" :prompt "Command: ")] ["Actions" - ("c" "Create" kubed-create)]) + ("c" "Create" kubed-create) + ("!" "Command line" kubed-kubectl-command)] + (interactive) + (transient-setup 'kubed-transient-create-deployment nil nil + :scope '("create" "deployment"))) (provide 'kubed-transient) ;;; kubed-transient.el ends here diff --git a/lisp/net/kubed.el b/lisp/net/kubed.el index 9f0eb7b775c..ffb5296e9e8 100644 --- a/lisp/net/kubed.el +++ b/lisp/net/kubed.el @@ -1275,6 +1275,8 @@ Optional argument DEFAULT is the minibuffer default argument." (defvar kubed-kubectl-command-history nil "Minibuffer history for `kubed-kubectl-command'.") +(defvar transient-current-command) + ;;;###autoload (defun kubed-kubectl-command (command) "Execute `kubectl' COMMAND. @@ -1283,8 +1285,21 @@ This function calls `shell-command' (which see) to do the work. Interactively, prompt for COMMAND with completion for `kubectl' arguments." (interactive - (list (cobra-read-command-line "Command: " "kubectl " - 'kubed-kubectl-command-history))) + (list (cobra-read-command-line + "Command: " + (concat + kubed-kubectl-program " " + (when-let + ((args + (and (fboundp 'transient-args) + (fboundp 'transient-scope) + transient-current-command + (string-join + (append (transient-scope) + (transient-args transient-current-command)) + " ")))) + (concat args " "))) + 'kubed-kubectl-command-history))) (shell-command command)) ;;;###autoload (autoload 'kubed-prefix-map "kubed" nil t 'keymap)