% This file demonstrates the use of the l3keys2e module to allow
% LaTeX3 keyvals (created using l3keys) to be used as LaTeX2e
% package or class options.
%

% First, create a class
\begin{filecontents}{l3keys2e-class.cls}
  \LoadClass{article}
  \RequirePackage{l3keys2e}
  \ProvidesExplClass{l3keys2e-class}{0000/00/00}{0.0}{test}
  \keys_define:nn { test1 } {
    option1 .code:n = {\wlog{You~gave~`#1'~for~option1}}
  }
  \ProcessKeysOptions { test1 }
\end{filecontents}

% Load the class with some options.
% The class itself recognises `option1', leaving `option2' and
% `option3' as global options which are not yet used.
\documentclass[option1=check,option2=more stuff,option3=unused]
  {l3keys2e-class}

%Now create a package
\begin{filecontents}{l3keys2e-package.sty}
  \RequirePackage{l3keys2e}
  \ProvidesExplPackage{l3keys2e-package}{0000/00/00}{0.0}{test}
  \keys_define:nn { test2 } {
    option1 .code:n = {\wlog{You~gave~`#1'~for~option1~(again)}},
    option2 .code:n = {\wlog{You~gave~`#1'~for~option2}},
    option4 .code:n = {\wlog{You~gave~`#1'~for~option4}},
  }
  \ProcessKeysOptions { test2 }
\end{filecontents}

% Load the package.
\usepackage[option4={extra stuff},option5=undefined!]
  {l3keys2e-package}

\begin{document}
% The log should show that option3 is an unused global option, and that
% option5 is not known by the l3keys2e-demo package. Everything else
% should simply be listed in the log.
\end{document}
