I have trouble understanding how to properly use tikz keys and pass them. Let's say I want to code two tikz pics with both a "fill" argument. I sometimes end up writing things like the example below. But rather than using \ifmyfillA I would like to "pass" the boolean value to cmdB, is there a simple one-line way to do that? This code seems messy but I can't figure out the proper way to do it.
[edit] Changing to true MWE. Now cmdB is drawing a rectangle that can be filled or not. cmdA is just a wrapper calling cmdB. The goal is to get rid of the \if … \else … \fi block, and just replace it with one line.
\documentclass[]{article}
\usepackage{tikz}
\newif\ifmyfillA
\newif\ifmyfillB
\tikzset{
cmdA/args/fill/.is if=myfillA,
cmdA/args/fill=false,
cmdA/.pic={
\pgfqkeys{/tikz/cmdA/args}{#1}
\ifmyfillA
\pic[] at (0,0) {cmdB={fill}};
\else
\pic at (0,0) {cmdB={}};
\fi
},
cmdB/args/fill/.is if=myfillB,
cmdB/args/fill=false,
cmdB/.pic={
\pgfqkeys{/tikz/cmdB/args}{#1}
\ifmyfillB
\draw[fill] (-1,-1) rectangle (1,1);
\else
\draw[] (-1,-1) rectangle (1,1);
\fi
}
}
\begin{document}
\begin{tikzpicture}
\pic[red] at (0,0) {cmdA};
\pic[blue] at (3,0) {cmdA={fill}};
\end{tikzpicture}
\end{document}


However see the example in page 889 of the tikz-pgf manual!
– Hafid Boukhoulda Jan 06 '19 at 17:08is ifkey which is described in a very nice example on p. 889 of the pgfmanual. (But please don not abuse it, otherwise the earth may become flat! ;-) – Jan 06 '19 at 17:12cmdBandcmdAis. Isn'tcmdA/.pic={ \ifmyfillA \pic at (0,0) {cmdB={fill}} \else \pic at (0,0) {cmdB={}} \fi }a recursion? Apicis a code. And then you tell TikZ to set thepicto be code to call apic. Please make an MWE that works withoutis ifand then it will be straightforward to add theis if. – Jan 06 '19 at 17:21\documentclassand ends with\end{document}– Hafid Boukhoulda Jan 06 '19 at 17:22fill=/tikz/cmdA/args/fill… but obviously that's not the way to do it. – Zooky Jan 06 '19 at 17:50