Consider the following:
\documentclass{article}
\usepackage{xparse}
\ExplSyntaxOn
\NewDocumentCommand{\demo}{m}{
\str_case:nnF{#1}
{
{a} {Run case 1\ % Actually super long code
}
{b} {Run case 1\ % Actually super long code
}
}
{
% False code
}
}
\ExplSyntaxOff
\begin{document}
\demo{a}
\demo{b}
\end{document}
Is there any way I can define the "b" case without having to copy all of my "actually super long code"?

xparsewith a sufficiently new TeX distribution. – Jasper Habicht Aug 08 '23 at 17:30\IfValueTFthat performs test on optional arguments to\demoand that sound prone to error and too complicated :-) – Clément Aug 08 '23 at 17:46