Another option is to use keyreader
\begin{filecontents}{mypack.sty}
\ProvidesPackage{mypack}
\usepackage{keyreader}
% Define the keys in family MYFAM and set the
% macor prefix to my@
\krddefinekeys{MYFAM}[my@]{
% define a command key 'say' that sores
% it’s value in \my@say
cmd/say/jump/;
% [1] define a boolean
bool/colori/true/;
% [2] define a boolean and store the value
bool/colorii/true/\def\my@colorii{#1};
}
% booleand are not preset by defualt so we
% do it manually
\krdsetkeys{MYFAM}{colori=false,colorii=false}
% Process the package options
\krdProcessOptions<MYFAM>\relax
% with version [1]
%\ifmy@colori
% \RequirePackage[colorlinks=true]{hyperref}
%\else
% \RequirePackage[colorlinks=false]{hyperref}
%\fi
% with version [2]
\RequirePackage[colorlinks=\my@colorii]{hyperref}
\newcommand{\mycmd}[1]{%
% use the value of 'say'
#1 says \my@say.
}
\end{filecontents}
\documentclass{article}
\usepackage[%
say={sit down},
colori=true,% [1]
colorii=false,% [2]
]{mypack}
\begin{document}
\mycmd{Simon}
\url{www.myurl.com}
\end{document}
Notes
hyperref
has no color
option (at least my version hasn’t)
Version [1] is the shorter was if you want to access only one hyperref
key
Version [2] is better if you want to access more then one option.
For that we store the value of the option an pass it to hyperref
later.
Booleans don’t store their value by default, they only create new \if…
Why not use a cmd
for this version? Because bool
key checks if it’t value
matches true or false
Maybe it’s better to use the pdf key processing since it’s more related with the beamer
class, but I’m not familiar with that.