Another option is to use kvoptions
and etoolbox
, in your .sty
file, write:
...
\RequirePackage{kvoptions}
\RequirePackage{etoolbox}
%% if the variable 'color' is
%% 1. not included : it will be set to 'false'
%% 2. included but not given a value: it will be set to 'true'
%% 3. included and given a value : it will be set to the value that is given
\DeclareStringOption[false]{color}[true]
\newif \ifcolor %% new Boolean variable is default to 'false'
\ifdefstring{\foo@color}{true}{\colortrue}{} %% set the Boolean variable to 'true' if '\foo@color' is 'true'
\ifcolor
\RequirePackage[color = true]{hyperref}
\else
\RequirePackage[color = false]{hyperref}
\fi
...
Then in your document you can specify the option 'color' with:
...
\usepackage[color]{foo} %% color = true
\usepackage[color = true]{foo} %% color = true
\usepackage[color = false]{foo} %% color = false
...