xkeyval provides \DeclareOptionX which effectively defines a key like \define@key does but that can be used as a package option.
How can I \DeclareOptionXs that behave like \define@choicekey or \define@boolkey would?
I've done the following, but it isn't ideal.
\documentclass{article}
\usepackage{xkeyval}
\newcounter{testcounter}
\usepackage{filecontents}
\begin{filecontents}{testpackage.sty}
\define@boolkey{testpackage}{ffoo}{}
\DeclareOptionX{foo}{\setkeys{testpackage}{ffoo=#1}}
\ProcessOptionsX
\ifKV@testpackage@ffoo
\def\foo{Foo}
\else
\def\foo{Fail}
\fi
\end{filecontents}
\usepackage[foo=true]{testpackage}
\begin{document}
\foo
\end{document}
This isn't great since the error doesn't refer to the key it should refer to, that is, to the key that the user sets.
Is there some obvious way of doing this that I am missing?
\DeclareOptionXnot\DefineOptionX?] – Seamus Jul 18 '11 at 14:46