From 5cb64af94272bffd19672a1da5e8d3eeb6b8edd6 Mon Sep 17 00:00:00 2001 From: Eshel Yaron Date: Wed, 14 Aug 2024 21:13:04 +0200 Subject: [PATCH] Teach 'kubed-diff' about buffer-local contexts * kubed.el (kubed-diff): Use buffer-local context and handle prefix arg. * kubed-transient.el (kubed-transient-diff): Add "--context=" infix argument. --- kubed-transient.el | 4 +++- kubed.el | 10 +++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/kubed-transient.el b/kubed-transient.el index c63819a..829eedb 100644 --- a/kubed-transient.el +++ b/kubed-transient.el @@ -111,7 +111,9 @@ ("-M" "Include managed fields" "--show-managed-fields")] ["Options" ("-f" "Definition file" "--filename=" - :reader kubed-transient-read-resource-definition-file-name)]] + :reader kubed-transient-read-resource-definition-file-name) + ("-C" "Context" "--context=" + :prompt "Context" :reader kubed-transient-read-context)]] (interactive) (transient-setup 'kubed-transient-diff nil nil :scope '("diff"))) diff --git a/kubed.el b/kubed.el index 02aa2e2..d1a40b6 100644 --- a/kubed.el +++ b/kubed.el @@ -2805,15 +2805,19 @@ the current context; non-nil INCLUDE-MANAGED (interactively, the prefix argument) says to include managed fields in the comparison." (interactive (let ((definition nil) (context nil) (include-managed nil)) - (dolist (arg (when (and (fboundp 'transient-args) - (fboundp 'kubed-transient-diff)) - (transient-args 'kubed-transient-diff))) + (dolist (arg (kubed-transient-args 'kubed-transient-diff)) (cond ((string-match "--filename=\\(.+\\)" arg) (setq definition (match-string 1 arg))) ((string-match "--context=\\(.+\\)" arg) (setq context (match-string 1 arg))) ((equal "--show-managed-fields" arg) (setq include-managed t)))) + (unless context + (setq context + (let ((cxt (kubed-local-context))) + (if (equal current-prefix-arg '(16)) + (kubed-read-context "Context" cxt) + cxt)))) (list (or definition (kubed-read-resource-definition-file-name)) (or include-managed current-prefix-arg) context))) -- 2.39.5