]> git.eshelyaron.com Git - emacs.git/commitdiff
Integrate 'kubed-kubectl-command' with transient menus
authorEshel Yaron <me@eshelyaron.com>
Thu, 25 Jul 2024 08:16:10 +0000 (10:16 +0200)
committerEshel Yaron <me@eshelyaron.com>
Thu, 25 Jul 2024 08:16:10 +0000 (10:16 +0200)
lisp/net/kubed-transient.el
lisp/net/kubed.el

index d53b42223a1d98d507ff0975f79ca2e0395352bd..6bd15655d9b6ba1702fe2ad71a86f2489b79dcfa 100644 (file)
    ("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 ()
    ("--" "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
index 9f0eb7b775cd9a96cb20bcf205c86fb61b2bf5d8..ffb5296e9e86555be914ceaabc02665a2028448c 100644 (file)
@@ -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)