Replies: 3 comments 2 replies
-
|
A better test case: Details(defvar demo-inapt nil)
(transient-define-suffix demo-toggle-inapt ()
:key "t"
:description (##format "Toggle inapt (%s)" demo-inapt)
(interactive)
(setq demo-inapt (not demo-inapt)))
(transient-define-argument demo--a ()
:class 'transient-option
:key "a"
:description "Honor inapt"
:argument "--a="
:choices '("1" "2")
:inapt-if-non-nil 'demo-inapt)
(transient-define-argument demo--b ()
:class 'transient-option
:key "b"
:description "Ignore inapt"
:argument "--b="
:choices '("1" "2"))
(transient-define-argument demo--c ()
:class 'transient-option
:key "c"
:description "Honor inapt via group"
:argument "--c="
:choices '("1" "2"))
(transient-define-prefix demo ()
:refresh-suffixes t
:transient-suffix t
:value '("--a=1" "--b=1" "--c=1")
[(demo-toggle-inapt)
(demo--a)
(demo--b)
(transient-echo-arguments)]
[:inapt-if-non-nil demo-inapt
(demo--c)])I've pushed something to the |
Beta Was this translation helpful? Give feedback.
-
|
Hey @tarsius Wow, that was quick, thanks for the update. I want to test the changes and report back but I can't see the 407 branch in this repository. Is it somewhere else or not public? Thanks |
Beta Was this translation helpful? Give feedback.
-
|
I've just pushed support for this and the related #316 and #364. The whole commit series deals with this, but the more interesting commits include b4edb63, 6322fc7, b44be23 and e144e9c, where it all comes together. Here's the test prefix used to test the features requested in the three topics: Details;; -*- lexical-binding: t -*-
(defun demo-predicate ()
(transient-arg-value "-a" (transient-get-value)))
(transient-define-argument demo--a ()
:class 'transient-switch
:description "Predicate switch"
:argument "-a")
(transient-define-argument demo--b ()
:class 'transient-switch
:description "if switch"
:argument "-b"
:if #'demo-predicate)
(transient-define-argument demo--c ()
:class 'transient-switch
:description "inapt-if-not switch"
:argument "-c"
:inapt-if-not #'demo-predicate)
(transient-define-argument demo--d ()
:class 'transient-option
:description "inapt-if-not option"
:argument "--d="
:choices '("1" "2")
:inapt-if-not #'demo-predicate)
(transient-define-prefix demo ()
:refresh-suffixes t
:transient-suffix t
:value '("-a" "-b" "-c" "--d=1" "-e" "-f" "-g")
[("a" demo--a)
( :info "(placeholder)"
:face transient-inapt-suffix
:if-not demo-predicate)
("b" demo--b)
("c" demo--c)
("d" demo--d)]
[("e" "regular switch" "-e")
("f" "level 7 switch" "-f" :level 7)
("g" "level 0 switch" "-g" :level 0)]
[(:info* (##format "Extended arguments: %s" (transient--get-extended-value)))
(:info* (##format "Active arguments: %s" (transient-get-value)))
(transient-echo-arguments)]) |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have an argument:
and this is the prefix that contains this argument:
Even though I set
--output=yamlin:value, whenever:inapt-if's condition returnsnil,--outputis not set toyamlautomatically.I don't know if this is expected and, if it is, how can I set a default value for an argument that has an
:inept-if?:valueseems to work for any other argument though, like--revision=, just fine.Thanks.
Beta Was this translation helpful? Give feedback.
All reactions