You can use the package pgfkeys for setting up a key-val interface.
The package pgfkeys is a component of the packages TikZ and pgf.
The package pgfkeys is explained in Part VII: Utilities, section 88 - Key Management of pgfmanual.pdf. (pgfmanual.pdf is the manual for the packages TikZ and pgf.)
A starting-point could be:
\documentclass{article}
\usepackage{pgfkeys}
\makeatletter
\newcommand\MapNewCVInfoValueKeyToMacro[3]{%
% #1 = key
% #2 = initial definition text of internal macro
% #3 = internal macro to define from value of key
\@ifdefinable#3{%
\pgfkeys{#1/.value required, #1/.store in=#3, #1=#2}%
}%
}%
\@ifdefinable\ifdashedborder{%
\@ifdefinable\dashborderfalse{%
\@ifdefinable\dashbordertrue{%
\newif\ifdashedborder\dashedborderfalse
}%
}%
}%
\pgfkeys{%
/CVInfo/RoundedPictureOptions/Border/dashed/.is if=dashedborder,
/CVInfo/RoundedPictureOptions/Border/dashed=true,
/CVInfo/RoundedPictureOptions/Border/dashed/.value required,
/CVInfo/RoundedPictureOptions/.code=\pgfkeys{/CVInfo/RoundedPictureOptions/.cd,#1},
/CVInfo/RoundedPictureOptions/.value required,
/CVInfo/RoundedPictureOptions/Border/.code=\pgfkeys{/CVInfo/RoundedPictureOptions/Border/.cd,#1},
/CVInfo/RoundedPictureOptions/Border/.value required,
}%
\MapNewCVInfoValueKeyToMacro{/CVInfo/first name}{myFirstName}{\@Firstname}
\MapNewCVInfoValueKeyToMacro{/CVInfo/last name}{myLastName}{\@Lastname}
\MapNewCVInfoValueKeyToMacro{/CVInfo/email}{myEmail}{\@Email}
\MapNewCVInfoValueKeyToMacro{/CVInfo/phone}{myPhone}{\@Phone}
\MapNewCVInfoValueKeyToMacro{/CVInfo/picture}{myPicture}{\@Picture}
\MapNewCVInfoValueKeyToMacro{/CVInfo/RoundedPictureOptions/scale}{0.4}{\@Picturescale}
\MapNewCVInfoValueKeyToMacro{/CVInfo/RoundedPictureOptions/x shift}{-0.1cm}{\@Picturexshift}
\MapNewCVInfoValueKeyToMacro{/CVInfo/RoundedPictureOptions/y shift}{-0.4cm}{\@Pictureyshift}
\MapNewCVInfoValueKeyToMacro{/CVInfo/RoundedPictureOptions/Border/thickness}{thick}{\@Pictureborderthickness}
\MapNewCVInfoValueKeyToMacro{/CVInfo/RoundedPictureOptions/Border/color}{blue}{\@Picturebordercolor}
\newcommand\CVInfo[1][]{%
\pgfkeys{/CVInfo/.cd,#1}%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\message{%
^^J%
Internal macros are now defined as follows:^^J%
\string\@Firstname: \meaning\@Firstname^^J%
\string\@Lastname: \meaning\@Lastname^^J%
\string\@Email: \meaning\@Email^^J%
\string\@Phone: \meaning\@Phone^^J%
\string\@Picture: \meaning\@Picture^^J%
\string\@Picturescale: \meaning\@Picturescale^^J%
\string\@Picturexshift: \meaning\@Picturexshift^^J%
\string\@Pictureyshift: \meaning\@Pictureyshift^^J%
\string\ifdashedborder: \meaning\ifdashedborder^^J%
\string\@Pictureborderthickness: \meaning\@Pictureborderthickness^^J%
\string\@Picturebordercolor: \meaning\@Picturebordercolor^^J%
}%
}%
\makeatother
\CVInfo
\CVInfo[%
first name=John,
last name=Doe,
picture=JohnDoe.jpg,
RoundedPictureOptions={
scale=0.8,
x shift=0.6cm,
y shift=0.8cm,
Border={
dashed=false,
thickness=not so thick,
color=red
}%
},
email=john\str[email protected],
phone=123456
]
\begin{document}
\end{document}
When compiling the example above, the terminal will tell you the following:
$ pdflatex -shell-escape test.tex
This is pdfTeX, Version 3.14159265-2.6-1.40.19 (TeX Live 2019/dev/Debian) (preloaded format=pdflatex)
\write18 enabled.
entering extended mode
(./test.tex
LaTeX2e <2018-12-01>
(/usr/share/texlive/texmf-dist/tex/latex/base/article.cls
Document Class: article 2018/09/03 v1.4i Standard LaTeX document class
(/usr/share/texlive/texmf-dist/tex/latex/base/size10.clo))
(/usr/share/texlive/texmf-dist/tex/latex/pgf/utilities/pgfkeys.sty
(/usr/share/texlive/texmf-dist/tex/generic/pgf/utilities/pgfkeys.code.tex
(/usr/share/texlive/texmf-dist/tex/generic/pgf/utilities/pgfkeysfiltered.code.t
ex)))
Internal macros are now defined as follows:
\@Firstname: macro:->myFirstName
\@Lastname: macro:->myLastName
\@Email: macro:->myEmail
\@Phone: macro:->myPhone
\@Picture: macro:->myPicture
\@Picturescale: macro:->0.4
\@Picturexshift: macro:->-0.1cm
\@Pictureyshift: macro:->-0.4cm
\ifdashedborder: \iftrue
\@Pictureborderthickness: macro:->thick
\@Picturebordercolor: macro:->blue
Internal macros are now defined as follows:
\@Firstname: macro:->John
\@Lastname: macro:->Doe
\@Email: macro:->john\string @doe.com
\@Phone: macro:->123456
\@Picture: macro:->JohnDoe.jpg
\@Picturescale: macro:->0.8
\@Picturexshift: macro:->0.6cm
\@Pictureyshift: macro:->0.8cm
\ifdashedborder: \iffalse
\@Pictureborderthickness: macro:->not so thick
\@Picturebordercolor: macro:->red
(./test.aux) (./test.aux) )
No pages of output.
Transcript written on test.log.
The so-called key-tree of the pgfkeys package also serves as a database for storing whatsoever pieces of data.
Instead of defining internal macros, you can use \pgfkeysvalueof
for obtaining values of value-keys:
\documentclass{article}
\usepackage{pgfkeys}
\makeatletter
\newif\ifdashedborder\dashedborderfalse
\pgfkeys{%
/CVInfo/RoundedPictureOptions/Border/dashed/.is if=dashedborder,
/CVInfo/RoundedPictureOptions/Border/dashed=true,
/CVInfo/RoundedPictureOptions/Border/dashed/.value required,
/CVInfo/first name/.value required, /CVInfo/first name/.initial=myFirstName,
/CVInfo/last name/.value required, /CVInfo/last name/.initial=myLastName,
/CVInfo/email/.value required, /CVInfo/email/.initial=myEmail,
/CVInfo/phone/.value required, /CVInfo/phone/.initial=myPhone,
/CVInfo/picture/.value required, /CVInfo/picture/.initial=myPicture,
/CVInfo/RoundedPictureOptions/scale/.value required, /CVInfo/RoundedPictureOptions/scale/.initial=0.4,
/CVInfo/RoundedPictureOptions/x shift/.value required, /CVInfo/RoundedPictureOptions/x shift/.initial=-0.1cm,
/CVInfo/RoundedPictureOptions/y shift/.value required, /CVInfo/RoundedPictureOptions/y shift/.initial=-0.4cm,
/CVInfo/RoundedPictureOptions/Border/thickness/.value required, /CVInfo/RoundedPictureOptions/Border/thickness/.initial=thick,
/CVInfo/RoundedPictureOptions/Border/color/.value required, /CVInfo/RoundedPictureOptions/Border/color/.initial=blue,
/CVInfo/RoundedPictureOptions/.code=\pgfkeys{/CVInfo/RoundedPictureOptions/.cd,#1},
/CVInfo/RoundedPictureOptions/.value required,
/CVInfo/RoundedPictureOptions/Border/.code=\pgfkeys{/CVInfo/RoundedPictureOptions/Border/.cd,#1},
/CVInfo/RoundedPictureOptions/Border/.value required
}%
\newcommand\CVInfo[1][]{%
\pgfkeys{/CVInfo/.cd,#1}%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\message{%
^^J%
Values of keys are set as follows:^^J%
/CVInfo/first name=\pgfkeysvalueof{/CVInfo/first name}^^J%
/CVInfo/last name=\pgfkeysvalueof{/CVInfo/last name}^^J%
/CVInfo/email=\pgfkeysvalueof{/CVInfo/email}^^J%
/CVInfo/phone=\pgfkeysvalueof{/CVInfo/phone}^^J%
/CVInfo/picture=\pgfkeysvalueof{/CVInfo/picture}^^J%
/CVInfo/RoundedPictureOptions/scale=\pgfkeysvalueof{/CVInfo/RoundedPictureOptions/scale}^^J%
/CVInfo/RoundedPictureOptions/x shift=\pgfkeysvalueof{/CVInfo/RoundedPictureOptions/x shift}^^J%
/CVInfo/RoundedPictureOptions/y shift=\pgfkeysvalueof{/CVInfo/RoundedPictureOptions/y shift}^^J%
\string\ifdashedborder: \meaning\ifdashedborder^^J%
/CVInfo/RoundedPictureOptions/Border/thickness=\pgfkeysvalueof{/CVInfo/RoundedPictureOptions/Border/thickness}^^J%
/CVInfo/RoundedPictureOptions/Border/color=\pgfkeysvalueof{/CVInfo/RoundedPictureOptions/Border/color}^^J%
}%
}%
\makeatother
\CVInfo
\CVInfo[%
first name=John,
last name=Doe,
picture=JohnDoe.jpg,
RoundedPictureOptions={%
scale=0.8,
x shift=0.6cm,
y shift=0.8cm,
Border={%
dashed=false,
thickness=not so thick,
color=red
}%
},
email=john\str[email protected],
phone=123456
]
\begin{document}
\end{document}
When compiling the example above, the terminal will tell you the following:
$ pdflatex -shell-escape test.tex
This is pdfTeX, Version 3.14159265-2.6-1.40.19 (TeX Live 2019/dev/Debian) (preloaded format=pdflatex)
\write18 enabled.
entering extended mode
(./test.tex
LaTeX2e <2018-12-01>
(/usr/share/texlive/texmf-dist/tex/latex/base/article.cls
Document Class: article 2018/09/03 v1.4i Standard LaTeX document class
(/usr/share/texlive/texmf-dist/tex/latex/base/size10.clo))
(/usr/share/texlive/texmf-dist/tex/latex/pgf/utilities/pgfkeys.sty
(/usr/share/texlive/texmf-dist/tex/generic/pgf/utilities/pgfkeys.code.tex
(/usr/share/texlive/texmf-dist/tex/generic/pgf/utilities/pgfkeysfiltered.code.t
ex)))
Values of keys are set as follows:
/CVInfo/first name=myFirstName
/CVInfo/last name=myLastName
/CVInfo/email=myEmail
/CVInfo/phone=myPhone
/CVInfo/picture=myPicture
/CVInfo/RoundedPictureOptions/scale=0.4
/CVInfo/RoundedPictureOptions/x shift=-0.1cm
/CVInfo/RoundedPictureOptions/y shift=-0.4cm
\ifdashedborder: \iftrue
/CVInfo/RoundedPictureOptions/Border/thickness=thick
/CVInfo/RoundedPictureOptions/Border/color=blue
Values of keys are set as follows:
/CVInfo/first name=John
/CVInfo/last name=Doe
/CVInfo/[email protected]
/CVInfo/phone=123456
/CVInfo/picture=JohnDoe.jpg
/CVInfo/RoundedPictureOptions/scale=0.8
/CVInfo/RoundedPictureOptions/x shift=0.6cm
/CVInfo/RoundedPictureOptions/y shift=0.8cm
\ifdashedborder: \iffalse
/CVInfo/RoundedPictureOptions/Border/thickness=not so thick
/CVInfo/RoundedPictureOptions/Border/color=red
(./test.aux) (./test.aux) )
No pages of output.
Transcript written on test.log.
You may wish to turn /CVInfo/RoundedPictureOptions/Border/thickness
into a choice-key.
\CVInfo
macro set a switch, and then have the inside commands check for whether that switch is true. But I think thepgfkeys
solution below is better.\FirstName
not be executed and thus\@firstName
not be redefined?