% Created 2021-06-08 Tue 15:31
% Intended LaTeX compiler: pdflatex
\documentclass[10pt]{amsart}
    \usepackage[english]{isodate}
    \isodate

    \usepackage[utf8]{inputenc}
    \usepackage[T1]{fontenc}
    \usepackage{graphicx}
    \usepackage{longtable}
    \usepackage{float}
    \usepackage{wrapfig}
    \usepackage{rotating}

    \usepackage{fixltx2e}
    \usepackage[normalem]{ulem}
    \usepackage{textcomp}
    \usepackage{marvosym}

    \usepackage[top=2.8cm, bottom=2.8cm, left=3.0cm, right=3.0cm]{geometry}
    \usepackage{booktabs}
    \usepackage{amsfonts}
    \usepackage{amssymb}
    \usepackage{amsmath}

    \usepackage{amsthm}
    \usepackage{amsbsy}
    \usepackage{mathrsfs, calrsfs}
    \usepackage{stmaryrd}
    \usepackage{fancyvrb}

    \usepackage[usenames,dvipsnames]{xcolor}
    \usepackage{stackengine}
    \usepackage{hyperref}
    \usepackage[all]{hypcap}
    \hypersetup{
    colorlinks=true,
    linkcolor=RoyalBlue,
    urlcolor=NavyBlue,
    citecolor=ForestGreen}

    \usepackage{xcolor}
    \usepackage[most]{tcolorbox}
    \usepackage{empheq}
    \usepackage{environ}

    \usepackage{pgf}
    \usepackage{tikz}
    \usetikzlibrary{arrows,automata,backgrounds,calc,fit,matrix,positioning,shadows,shapes}
    \usepackage{dot2texi}
    \usepackage{txfonts}

    \usepackage{etoolbox}
    \makeatletter
    \let\ams@starttoc\@starttoc
    \makeatother
    \usepackage[parfill]{parskip}
    \makeatletter
    \let\@starttoc\ams@starttoc
    \patchcmd{\@starttoc}{\makeatletter}{\makeatletter\parskip\z@}{}{}
    \makeatother

    \let\oldtocsection=\tocsection
    \let\oldtocsubsection=\tocsubsection
    \let\oldtocsubsubsection=\tocsubsubsection
    \renewcommand{\tocsection}[2]{\hspace{0em}\oldtocsection{#1}{#2}}
    \renewcommand{\tocsubsection}[2]{\hspace{1em}\oldtocsubsection{#1}{#2}}
    \renewcommand{\tocsubsubsection}[2]{\hspace{2em}\oldtocsubsubsection{#1}{#2}}

    \usepackage{enumerate}
    \usepackage{multicol}
    \usepackage{multirow}
    \usepackage{microtype}

    \numberwithin{equation}{section}
    \setcounter{tocdepth}{4}
    \DeclareMathOperator{\Var}{Var}
    \DeclareMathOperator{\Cov}{cov}

    \RequirePackage{fancyvrb}
    \DefineVerbatimEnvironment{verbatim}{Verbatim}{fontsize=\scriptsize}
    \definecolor{lightgreen}{HTML}{90EE90}
    \definecolor{lightblue}{rgb}{0.94,0.94,0.95}


\usepackage{float}
\usepackage{fixltx2e}
\usepackage[normalem]{ulem}
\usepackage{textcomp}
\usepackage{marvosym}
\usepackage{booktabs}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{amsbsy}
\usepackage{mathrsfs}
\usepackage{calrsfs}
\usepackage{stmaryrd}
\usepackage{fancyvrb}
\usepackage{dsfont}
\usepackage{xcolor}
\usepackage[most]{tcolorbox}
\usepackage{empheq}
\usepackage{environ}
\usepackage{pgf}
\usepackage{tikz}
\usepackage{dot2texi}
\usepackage{txfonts}
\usepackage{enumerate}
\usepackage{multicol}
\usepackage{multirow}
\usepackage{microtype}
\usepackage[makeroom]{cancel}
\usepackage{minted}
\usemintedstyle{colorful}
\usepackage[ruled]{algorithm2e}
\usepackage{enumitem}
\newtheorem{lemma}{Lemma}[section]
\newtheorem{defn}{Definition}[section]
\newtheorem{remark}{Remark}[section]
\usepackage{mdframed}
\BeforeBeginEnvironment{verbatim}{\begin{mdframed}}
\AfterEndEnvironment{verbatim}{\end{mdframed}}
\author{Thomas P. Harte}
\date{\today}
\title{\texttt{parsearg}: turns \texttt{argparse} on its head, the declarative way}
\hypersetup{
 pdfauthor={Thomas P. Harte},
 pdftitle={\texttt{parsearg}: turns \texttt{argparse} on its head, the declarative way},
 pdfkeywords={},
 pdfsubject={},
 pdfcreator={Emacs 27.1 (Org mode 9.2.5)}, 
 pdflang={English}}
\begin{document}

\maketitle
\tableofcontents

% inverse:
\newcommand{\inv}[1]{{#1}^{-1}}

%    Enclose the argument in vert-bar delimiters:
\newcommand{\envert}[1]{\left\lvert#1\right\rvert}
\let\abs=\envert

%    Enclose the argument in double-vert-bar delimiters:
\newcommand{\enVert}[1]{\left\lVert#1\right\rVert}

% define the vector norm
\let\norm=\enVert

% bootstrap / cross-validation definitions:
\newcommand{\PE}{\mbox{PE}}             % Predictive error

% financial definitions:
\newcommand{\EVA}{\mbox{EVA}}             % Economic Value Added
\newcommand{\CTE}{\mbox{CTE}}             % Conditional tail expectation (expected shortfall)
\newcommand{\VaR}{\mbox{VaR}}             % Value-at-Risk
\newcommand{\PAR}{\mbox{PAR}}             % PAR value of a bond
%% \newcommand{\AC}{\mbox{AC}}             % accrued interest of a bond
\newcommand{\TR}{\mbox{TR}}             % total return

% text definitions:
\newcommand{\Primafacie}{\emph{Prima facie\/}}
\newcommand{\primafacie}{\emph{prima facie\/}}
\newcommand{\Mutatis}{\emph{Mutatis mutandis\/}}
\newcommand{\mutatis}{\emph{mutatis mutandis\/}}
\newcommand{\Apriori}{\emph{A~priori\/}}
\newcommand{\apriori}{\emph{a~priori\/}}
\newcommand{\Adhoc}{\emph{Ad~hoc\/}}
\newcommand{\adhoc}{\emph{ad~hoc\/}}
\newcommand{\qua}{\emph{qua\/}}
\newcommand{\etc}{\emph{etc.\/}}
\newcommand{\ie}{\emph{i.e.\/}}
\newcommand{\eg}{\emph{e.g.\/}}
\newcommand{\viz}{\emph{viz.\/}}
\newcommand{\perse}{\emph{per~se\/}}
\newcommand{\intoto}{\emph{in~toto\/}}
\newcommand{\interalia}{\emph{inter~alia\/}}
\newcommand{\notabene}{\emph{nota~bene\/}}
\newcommand{\Notabene}{\emph{Nota~bene\/}}
\newcommand{\etal}{\emph{et~al.,\/}}
\newcommand{\cf}{cf.\/}                % confer (L.)
\newcommand{\sic}{[\emph{sic}]}
\newcommand{\etseq}{\emph{et~seq.\/}}        % et sequens (L.)
\newcommand{\etsqq}{\emph{et~sqq.\/}}        % et sequentia (L.)
\newcommand{\Page}{\emph{p.\/}}            % ``page''  (page number)
\newcommand{\pp}{\emph{pp.\/}}            % ``pages'' (page numbers)
\newcommand{\visavis}{\emph{vis~\`a~vis\/}}    % vis a vis (F.)

% fields and things:
\newcommand{\field}[1]{\mathbb{#1}}
\newcommand{\BB}{\field{B}}
\newcommand{\CC}{\field{C}}
\newcommand{\EE}{\field{E}}
\newcommand{\FF}{\field{F}}
\newcommand{\MM}{\field{N}}
\newcommand{\NN}{\field{N}}
\newcommand{\PP}{\field{P}}
\newcommand{\QQ}{\field{Q}}
\newcommand{\RR}{\field{R}}
\newcommand{\VV}{\field{V}}
\newcommand{\WW}{\field{W}}
\newcommand{\XX}{\field{X}}
\newcommand{\ZZ}{\field{Z}}

\newcommand{\ww}{\mathrm{w}}

% vectors
\newcommand{\va}{\vec{a}}
\newcommand{\vb}{\vec{b}}
\newcommand{\vc}{\vec{c}}
\newcommand{\vd}{\vec{d}}
\newcommand{\ve}{\vec{e}}
\newcommand{\vf}{\vec{f}}
\newcommand{\vg}{\vec{g}}
\newcommand{\vh}{\vec{h}}
\newcommand{\vi}{\vec{i}}
\newcommand{\vj}{\vec{j}}
\newcommand{\vk}{\vec{k}}
\newcommand{\vl}{\vec{l}}
\newcommand{\vm}{\vec{m}}
\newcommand{\vn}{\vec{n}}
\newcommand{\vo}{\vec{o}}
\newcommand{\vp}{\vec{p}}
\newcommand{\vq}{\vec{q}}
\newcommand{\vr}{\vec{r}}
\newcommand{\vs}{\vec{s}}
\newcommand{\vt}{\vec{t}}
\newcommand{\vu}{\vec{u}}
\newcommand{\vv}{\vec{v}}
\newcommand{\vw}{\vec{w}}
\newcommand{\vx}{\vec{x}}
\newcommand{\vy}{\vec{y}}
\newcommand{\vz}{\vec{z}}

% rank
\newcommand{\rank}[1]{
         { \mbox{rank}\left[{#1}\right] } 
}

% Basis vector
% requires \usepackage{amsmath}:
\newcommand{\Eone}{{\left(\substack{1\\0}\right)}}

\newcommand{\logm}{\mbox{logm}}

%% PROBABILITY SYMBOLS
%
% covariance matrix (boldsymbol requires the package amsbsy in AMS documents)
\newcommand{\covar}{\boldsymbol{\Sigma}}
% Expectation operator
% \newcommand{\Ex}[1]{
%          { {\mathcal E}\!\left[{#1}\right] }
% }
% \newcommand{\Ex}[1]{
%          { {\mathscr E}\!\left[{#1}\right] }         % \mathscr requires the mathrsfs package
% }

% Expectation
\newcommand{\Ex}[1]{
         { {\varmathbb E}\!\left[{#1}\right] }         % \varmathbb requires the txfonts package
}
% Squared expectation
\newcommand{\ExSq}[1]{
         { {\varmathbb E}^2\!\left[{#1}\right] }     % \varmathbb requires the txfonts package
}
% Expectation : subscript
\newcommand{\EX}[2]{
         { {\varmathbb E_{#2}}\!\left[{#1}\right] }         % \varmathbb requires the txfonts package
}
% Full Expectation : subscript & superscript
% \ExFull{ (y-\widehat{y})^2 }{0,\widehat F}{p}
\newcommand{\ExFull}[3]{
         { {\varmathbb E}_{#2}^{#3} \!\left[{#1}\right] } % requires the txfonts package
}

% Variance (VAR to avoid clashes with LaTeX's Var)
\newcommand{\VAR}[1]{
         { \VV\!\left[{#1}\right] }         
}
% Covariance (COV to avoid clashes with LaTeX's Cov)
\newcommand{\COV}[1]{
         { \mbox{\sc Cov}\!\left[{#1}\right] }         
}
% Standard deviation 
\newcommand{\SD}[1]{
         { \mbox{\sc SD}\!\left[{#1}\right] }         
}

% \abs  & \norm are already defined somewhere...
% absolute value
% \newcommand{\abs}[1]{\lvert#1\rvert}
% norm
% \newcommand{\norm}[1]{\lVert#1\rVert}

% std : standard deviation
\newcommand{\std}{\mbox{std}}   %
% diag:
\newcommand{\diag}{\mbox{diag}}   %


\newcommand{\Xbar}{\overline{X}}
\newcommand{\xbar}{\overline{x}}
\newcommand{\Ybar}{\overline{Y}}
\newcommand{\ybar}{\overline{y}}
% NOTE: \mathop works where \stackrel fails due to improper subscript sizing
%
% argmax
%% \newcommand{\argmax}[1]{
%%          { \mathop{\arg\max}_{ {#1} }\ }   % note: needs the trailing '\' to space text correctly
%% }
%% % argmin
%% \newcommand{\argmin}[1]{
%%          { \mathop{\arg\min}_{ {#1} }\ }   % note: needs the trailing '\' to space text correctly
%% }
%% [2018-11-05]: now using e.g. the following:
\newcommand{\argmax}[1]{
    { \operatorname*{arg\,max}_{{#1}}\, }   % note: needs the trailing '\' to space text correctly
}

\newcommand{\argmin}[1]{
    { \operatorname*{arg\,min}_{{#1}}\, }   % note: needs the trailing '\' to space text correctly
}


% by definition equals
\newcommand{\iid}{\stackrel{\mbox{\tiny i.i.d.}}{\sim}}
\newcommand{\defeq}{\stackrel{\triangle}{=}}
\newcommand{\bydefn}{\stackrel{\text{def}}{=}}
\newcommand{\astmapsto}{\stackrel{\ast}{\mapsto}}


% inner product
\newcommand{\inner}[2]{
    { \langle {#1}, {#2} \rangle } 
}

% Source: https://tex.stackexchange.com/questions/370364/specific-type-of-box-around-equation
% 
\newcommand\redbox[1]{%
  \fboxsep=-2pt
  \def\tmp{\displaystyle\strut #1}
  \def\shadow{\makebox[.4pt]{$\tmp$}}
  \stackengine{0pt}{%
    \stackengine{0pt}{%
      \textcolor{red}{\fbox{~~$\phantom{\tmp}$~~}}%
    }{\color{white}\shadow\shadow\shadow\shadow\shadow\shadow\shadow%
      \shadow\shadow\shadow\shadow}{O}{c}{F}{F}{L}%
  }{$\tmp$}{O}{c}{F}{F}{L}
}

% Rates: present value and future value
\newcommand{\PV}{\mbox{PV}}
\newcommand{\FV}{\mbox{FV}}

% Structured Credit:
\newcommand{\CPR}{\mbox{CPR}}
\newcommand{\SMM}{\mbox{SMM}}

% combination
\newcommand{\nchoosek}[2]{
    {
        \left(
            \begin{matrix}
                    {#1} \cr
                    {#2} 
            \end{matrix}
        \right)
    }
}


% derivative, e.g. d^3/dx^3. call with
% \dd{f}{x}{} to get df\over dx
\newcommand{\dd}[3]{
    {
      {d^{#3}{#1} \over d{#2}^{#3}}
    }
}

% Partial derivative, e.g. \partial ^3/\partial x^3. Call with 
% \pdd{f}{x}{} to get \partial f\over\partial x
\newcommand{\pdd}[3]{
    \frac{\textstyle\partial^{#3}{#1}}  
         {\textstyle\partial{#2}^{#3}}
}


%
% boxedeq
%
\newcommand{\boxedeq}[2]{
  \begin{empheq}
    [box={\fboxsep=6pt\fbox}]{align}
    \label{#1}
    #2
  \end{empheq}
}

%
% coloredeq
%
%% \newcommand{\coloredeq}[2]{
%%   \begin{empheq}
%%     [box=\colorbox{lightgreen}]{align}
%%     {\ifthenelse{\isempty{#1}{}}{}{\label{#1}}}
%%     #2
%%   \end{empheq}
%% }

%%% FIXME 2019-04-10: make environment instead?

%
% coloredeq
%
\newcommand{\coloredeq}[2]{
  \begin{empheq}
    [box=\colorbox{lightgray}]{align}
    {
        \def\tmp{#1}
        \ifx\tmp\@empty
            % Nothing here!
        \else
            \label{#1}
        \fi
    }
    #2
  \end{empheq}
}

% SOLUTION 1 [from ~/j/dot/org/newenvironment]:
%
%     Source: https://tex.stackexchange.com/questions/5639/defining-a-new-environment-whose-contents-go-in-a-tikz-node/5642#5642
%
%     package environ manual: http://ctan.math.illinois.edu/macros/latex/contrib/environ/environ.pdf
%
% requires 
%
%    \usepackage{environ}
%    \usepackage{xcolor}
%    \usepackage{empheq}
%
\NewEnviron{coloredequation}[1][lightgray]{%
  \begin{empheq}
    [box=\colorbox{#1}]{align}
    \BODY
  \end{empheq}
}
\NewEnviron{coloredequation*}[1][lightgray]{%
  \begin{empheq}
    [box=\colorbox{#1}]{align*}
    \BODY
  \end{empheq}
}


%
% mymath
%
\newtcbox{\mymath}[1][]{%
    nobeforeafter, math upper, tcbox raise base,
    enhanced, colframe=blue!30!black,
    colback=blue!30, boxrule=1pt,
    #1
}

% Independence / conditional independence
% Whereas independence can be indicated with $\perp$, Dawid originally introduced
% ``double perpendicular'' symbol for independence, but now it is most 
% often used to indicated /conditional/ independence only.
%
% Source: https://tex.stackexchange.com/questions/154530/resolved-a-conditional-independence-symbol-that-looks-good-with-mid
\newcommand{\indep}{\mathrel{\text{\scalebox{1.07}{$\perp\mkern-10mu\perp$}}}}


% for use with \usepackage[russian,english]{babel}
\newcommand{\ru}[1]{
    { \foreignlanguage{russian}{{#1}} }   
}


%%%  INDICATOR FUNCTION 
% to fix error: 'LaTeX Error: Too many math alphabets used in version normal'
% Source:
%     https://tex.stackexchange.com/questions/26637/how-do-you-get-mathbb1-to-work-characteristic-function-of-a-set
% PROBLEM: package:dsfont co-existing with package:bm
% After a lot of trial and error I found that the issue was with package:bm
% which I duly removed from my default list

\newcommand{\indicator}[2]{
    % \usepackage{dsfont}:
    { \mathds{1}_{{#1}}({#2}) }
}

% logit
\newcommand{\logit}[1]{
    {\log\,\biggl(\frac{ {#1} }{1- {#1} }\biggr)}
}

\newtcbox{\mybox}[1][]{%
    nobeforeafter, math upper, tcbox raise base,
    enhanced, colframe=blue!30!black,
    colback=lightgreen!30, boxrule=0.5pt,
    #1
}

\section{Quickstart}
\label{sec:orgf483fed}
\subsection{Overview}
\label{sec:org41d2251}
\texttt{parsearg} is a Python package for writing command-line interfaces (``CLI'')
that augments (rather than replaces) the standard Python module for writing
CLIs, \texttt{argparse}. There is nothing wrong with \texttt{argparse}: It's fine in terms of
the \emph{functionality} that it provides, but it can be clunky to use, especially
when a program's structure has subcommands, or nested subcommands (\emph{i.e.}
subcommands that have subcommands).  Moreover, because of the imperative
nature of \texttt{argparse}, it makes it hard to understand how a program's interface
is structured (\emph{viz.} the program's ``view'').

\texttt{parsearg} puts a layer on top of \texttt{argparse} that makes writing a CLI easy. you
declare your CLI, \emph{i.e.} your program's view, with a \texttt{dict} so that the view
is a data structure (\emph{i.e.} pure configuration). The view declares the \emph{intent} of
the CLI and you are relieved of the trouble of having to instruct \texttt{argparse}
on how to put the CLI together: \texttt{parsearg} does that for you.

\subsection{Usage}
\label{sec:orge4f1139}
Suppose we wish to create a program called \texttt{todos.py} to manage the TO-DOs
of a set of different users. We want to have subprograms of \texttt{todos.py}; for
example, we may want to create a user (\texttt{python todos.py create user}, say),
or we may want to create a TO-DO for a particular user 
(\texttt{python todos.py create todo}, say).  
We might also want to add optional parameters to each subprogram such as
the user's email and phone number, or the TO-DO's due date. An invocation
of the program's CLI might look like the following:
\begin{minted}[frame=single,fontsize=\scriptsize,linenos,bgcolor=lightblue,mathescape=true]{bash}
python todos.py create user Bob --email=bob@email.com --phone=+1-212-555-1234
python todos.py create todo Bob 'taxes' --due-date=2021-05-17
\end{minted}
With \texttt{argparse}, the subprogram \texttt{create} would necessitate fiddling
with subparsers.  With \texttt{parsearg}, the CLI for the above is declared
with a \texttt{dict} and \texttt{parsearg.parser.ParseArg} supplants the normal use of
\texttt{argparse.ArgumentParser}. Moreover, the callback associated with
each subcommand is explicitly linked to its declaration.
\begin{minted}[frame=single,fontsize=\scriptsize,linenos,bgcolor=lightblue,mathescape=true]{python}
import sys
from parsearg.parser import ParseArg

def create_user(args):
    print(f'created user: {args.name!r} (email: {args.email}, phone: {args.phone})')

def create_todo(args):
    print(f'created TO-DO for user {args.user!r}: {args.title} (due: {args.due_date})')

view = {
    'create|user': {
        'callback':   create_user,
        'name':       {'help': 'create user name', 'action': 'store'},
        '-e|--email': {'help': "create user's email address", 'action': 'store', 'default': ''},
        '-p|--phone': {'help': "create user's phone number", 'action': 'store', 'default': ''},
    },
    'create|todo': {
        'callback':   create_todo,
        'user':       {'help': 'user name', 'action': 'store'},
        'title':      {'help': 'title of to-do', 'action': 'store'},
        '-d|--due-date': {'help': 'due date for the to-do', 'action': 'store', 'default': None},
    },
}

def main(args):
    # ParseArg takes the place of argparse.ArgumentParser
    parser = ParseArg(d=view)

    # parser.parse_args returns an argparse.Namespace
    ns     = parser.parse_args(args)

    # ns.callback contains the function in the 'callback' key of 'view'
    result = ns.callback(ns)

if __name__ == "__main__":
    args = sys.argv[1:] if len(sys.argv) > 1 else []

    main(' '.join(args))
\end{minted}
A fully worked version of the \texttt{todos.py} example is presented in the docs. The output
of the above is:
\begin{minted}[frame=single,fontsize=\scriptsize,linenos,bgcolor=lightblue,mathescape=true]{bash}
python todos.py create user Bob --email=bob@email.com --phone=212-555-1234
\end{minted}

\begin{verbatim}
created user: 'Bob' (email: bob@email.com, phone: 212-555-1234)
\end{verbatim}


\begin{minted}[frame=single,fontsize=\scriptsize,linenos,bgcolor=lightblue,mathescape=true]{bash}
python todos.py create todo Bob 'taxes' --due-date=2021-05-17
\end{minted}

\begin{verbatim}
created TO-DO for user 'Bob': taxes (due: 2021-05-17)
\end{verbatim}


Because \texttt{parsearg} is built on top of \texttt{argparse}, all the usual features
are available, such as the extensive help features (essentially
making the CLI self-documenting):
\begin{minted}[frame=single,fontsize=\scriptsize,linenos,bgcolor=lightblue,mathescape=true]{bash}
python todos.py --help
\end{minted}

\begin{verbatim}
usage: todos.py [-h] {create} ...

positional arguments:
  {create}

optional arguments:
  -h, --help  show this help message and exit
\end{verbatim}



\begin{minted}[frame=single,fontsize=\scriptsize,linenos,bgcolor=lightblue,mathescape=true]{bash}
python todos.py create --help
\end{minted}

\begin{verbatim}
usage: todos.py create [-h] {todo,user} ...

positional arguments:
  {todo,user}

optional arguments:
  -h, --help   show this help message and exit
\end{verbatim}


\begin{minted}[frame=single,fontsize=\scriptsize,linenos,bgcolor=lightblue,mathescape=true]{bash}
python todos.py create user --help
\end{minted}

\begin{verbatim}
usage: todos.py create user [-h] [-e EMAIL] [-p PHONE] name

positional arguments:
  name                  create user name

optional arguments:
  -h, --help            show this help message and exit
  -e EMAIL, --email EMAIL
                        create user's email address
  -p PHONE, --phone PHONE
                        create user's phone number
\end{verbatim}

\begin{minted}[frame=single,fontsize=\scriptsize,linenos,bgcolor=lightblue,mathescape=true]{bash}
python todos.py create todo --help
\end{minted}

\begin{verbatim}
usage: todos.py create todo [-h] [-d DUE_DATE] user title

positional arguments:
  user                  user name
  title                 title of to-do

optional arguments:
  -h, --help            show this help message and exit
  -d DUE_DATE, --due-date DUE_DATE
                        due date for the to-do
\end{verbatim}

\section{Overview}
\label{sec:org51eaf06}
The ``standard'' Python module for writing command-line interfaces (``CLI'') 
is \texttt{argparse}. It is standard in so far as it is one of the batteries 
that comes included with the Python distribution, so no special 
installation is required. 
Probably because \texttt{argparse} is a bit clunky to use,
many other (non-standard) packages have been developed for creating CLIs.
Why ``clunky''? Putting together a CLI with \texttt{argparse}
alone is nothing if not an exercise in imperative programming, and this
has three very negative consequences:

\begin{enumerate}
\item It obfuscates the intention of the CLI design;
\item It is prone to errors;
\item It discourages CLI design in the first instance; it
makes debugging a CLI design very difficult; and it makes refactoring or
re-configuring the CLI design overly burdensome.
\end{enumerate}

In spite of this clunkiness, \texttt{argparse} has everything we need in 
terms of functionality. \texttt{parsearg}, then, is nothing more than a layer
over \texttt{argparse} that exposes the \texttt{argparse} functionality via a \texttt{dict}.
The \texttt{dict} is the View component of the 
\href{https://en.wikipedia.org/wiki/Model–view–controller}{Model-View-Controller (``MVC'')}
design pattern. The \texttt{dict} embeds callbacks from the Controller component,
thereby achieving a clean separation of duties, which is what the MVC pattern
calls for. By separating the View component into a \texttt{dict}, the CLI design
can be expressed in a declarative way: \texttt{parsearg} manifests the \emph{intention}
of the CLI design without having to specify how that design is implemented
in terms of \texttt{argparse}'s parsers and subparsers (\texttt{parsearg} does that
for you).

Other packages---such as \href{https://click.palletsprojects.com}{\texttt{click}} and \href{https://micheles.github.io/plac/}{\texttt{plac}}---effectively
decorate functions that are part of the Controller with functionality
from the View. Unfortunately, while this may 
expose the functionality of \texttt{argparse} in a more friendly way
via the packages' decorators, it dissipates the elements of the View 
across the Controller and in so doing it makes the CLI design difficult to grasp.

The \texttt{parsearg} philosophy is that \texttt{argparse} is already good enough in terms
of the functionality that it provides, but that it just needs a little nudge
in terms of how it's used.  Arguments to be added to a CLI with \texttt{argparse}
can be clearly specified as data, as can the callbacks that
consume these arguments. \texttt{parsearg} takes advantage of this by specifiying
everything (in the View component of MVC) as a \texttt{dict}, from which \texttt{parsearg}
then generates a parser (or set of nested parsers) using \texttt{argparse}. 
The Controller is then free to use the generated parser.

The \texttt{parsearg} approach is declarative because it manifests the CLI design
in a data structure: a \texttt{dict}, which is one of Python's built-in data structures.
The keys of this \texttt{dict} form a flattened tree of the CLI's subcommands. 
Keys like \texttt{A|B|C} are easy to specify and neatly summarize the nested
hierarchy of subcommands: \texttt{A -> B -> C}. They are also easy to change. 
The magic, such as it is, of \texttt{parsearg} is that it unflattens 
this flattened tree into a tree of \texttt{argparse} parsers. \texttt{parsearg} requires nothing 
special: It works with Python out of the box, and therefore uses
what's already available without introducing dependencies.

Simple? The following examples should help.

\section{\texttt{parsearg.examples.todos}}
\label{sec:org40ee003}
Yet another To-Do app? Yes, because:

\begin{enumerate}
\item It illustrates a  sufficiently realistic, but not overly complex, problem;
\item It also illustrates the MVC pattern in the wild;
\item It shows how \texttt{parsearg} neatly segments the View component into a \texttt{dict}.
\end{enumerate}

Let's start with the outer layer of the onion. How do we interact with \texttt{todos.py}?
First, create some users in the \texttt{User} table with the \texttt{create user} subcommand of \texttt{todos.py}. 
Note that we do not (yet) have a phone number for user \texttt{bar}, nor do we have an email address
for user \texttt{qux}:
\begin{minted}[frame=single,fontsize=\scriptsize,linenos,bgcolor=lightblue,mathescape=true]{bash}
python todos.py create user foo -e foo@foo.com -p 212-555-1234
python todos.py create user bar -e bar@bar.com
python todos.py create user qux -p 212-123-5555
\end{minted}

\begin{verbatim}
created user: 'foo' (email: foo@foo.com, phone: 212-555-1234)
created user: 'bar' (email: bar@bar.com, phone: )
created user: 'qux' (email: , phone: 212-123-5555)
\end{verbatim}


Second, create some to-dos in the \texttt{Todo} table with the \texttt{create todo} subcommand of \texttt{todos.py}. 
\begin{minted}[frame=single,fontsize=\scriptsize,linenos,bgcolor=lightblue,mathescape=true]{bash}
python todos.py create todo foo title1 -c description1 -d 2020-11-30
python todos.py create todo foo title2 -c description2 --due-date=2020-12-31
python todos.py create todo qux todo-1 --description=Christmas-party -d 2020-11-30
python todos.py create todo qux todo-2 --description=New-Year-party
\end{minted}

\begin{verbatim}
usage: todos.py [-h] {create} ...
todos.py: error: unrecognized arguments: -c description1
usage: todos.py [-h] {create} ...
todos.py: error: unrecognized arguments: -c description2
usage: todos.py [-h] {create} ...
todos.py: error: unrecognized arguments: --description=Christmas-party
usage: todos.py [-h] {create} ...
todos.py: error: unrecognized arguments: --description=New-Year-party
\end{verbatim}


Let's make some changes to the records entered so far. We can add an email address
for user \texttt{qux} and a phone number for user \texttt{bar} using the \texttt{update user email} 
and \texttt{update user phone} subcommands, respectively:
\begin{minted}[frame=single,fontsize=\scriptsize,linenos,bgcolor=lightblue,mathescape=true]{bash}
python todos.py update user email qux qux@quxbar.com
python todos.py update user phone bar 203-555-1212
\end{minted}

\begin{verbatim}
usage: todos.py [-h] {create} ...
todos.py: error: invalid choice: 'update' (choose from 'create')
usage: todos.py [-h] {create} ...
todos.py: error: invalid choice: 'update' (choose from 'create')
\end{verbatim}


Now update two of the to-dos, changing the \texttt{title} and the \texttt{description} in the fourth
to-do using the \texttt{update todo title} and \texttt{update todo description} subcommands, respectively:
\begin{minted}[frame=single,fontsize=\scriptsize,linenos,bgcolor=lightblue,mathescape=true]{bash}
python todos.py update todo title 4 most-important
python todos.py update todo description 4 2021-party
\end{minted}

\begin{verbatim}
usage: todos.py [-h] {create} ...
todos.py: error: invalid choice: 'update' (choose from 'create')
usage: todos.py [-h] {create} ...
todos.py: error: invalid choice: 'update' (choose from 'create')
\end{verbatim}


\begin{minted}[frame=single,fontsize=\scriptsize,linenos,bgcolor=lightblue,mathescape=true]{bash}
python todos.py show users
python todos.py show todos
\end{minted}

\begin{verbatim}
usage: todos.py [-h] {create} ...
todos.py: error: invalid choice: 'show' (choose from 'create')
usage: todos.py [-h] {create} ...
todos.py: error: invalid choice: 'show' (choose from 'create')
\end{verbatim}


The result of these commands is that the two tables (\texttt{User} and \texttt{Todo})
are populated in a \href{https://www.sqlite.org/index.html}{SQLite} database:
\begin{minted}[frame=single,fontsize=\scriptsize,linenos,bgcolor=lightblue,mathescape=true]{bash}
sqlite3 todo.db 'select * from User;'
\end{minted}

\begin{verbatim}
Error: no such table: User
\end{verbatim}


\begin{minted}[frame=single,fontsize=\scriptsize,linenos,bgcolor=lightblue,mathescape=true]{bash}
sqlite3 todo.db 'select * from Todo;'
\end{minted}

\begin{verbatim}
Error: no such table: Todo
\end{verbatim}


Let's look at the Python code for \href{https://github.com/tharte/parsearg/blob/master/parsearg/examples/todos.py}{\texttt{todos.py}}.

The View component is entirely contained within a single \texttt{dict}, \emph{viz.} 
\texttt{view}, which has been formatted here for clarity using \texttt{parsearg.utils.show}:
\begin{minted}[frame=single,fontsize=\scriptsize,linenos,bgcolor=lightblue,mathescape=true]{python}
from parsearg.examples.todos import view
from parsearg.utils import show

show(view)
\end{minted}

\begin{verbatim}
'purge|users':
    'callback':
    <function purge_users at 0x7f11d6ff6700>
'purge|todos':
    'callback':
    <function purge_todos at 0x7f11d6fcfaf0>
'show|users':
    'callback':
    <function show_users at 0x7f11d6fcfb80>
'show|todos':
    'callback':
    <function show_todos at 0x7f11d6fcfc10>
'create|user':
    'callback':
    <function create_user at 0x7f11d6fcfca0>
    'name':
    {'help': 'create user name', 'action': 'store'}
    '-e|--email':
    {'help': "create user's email address", 'action': 'store', 'default': ''}
    '-p|--phone':
    {'help': "create user's phone number", 'action': 'store', 'default': ''}
'create|todo':
    'callback':
    <function create_todo at 0x7f11d6fcfd30>
    'user':
    {'help': 'user name', 'action': 'store'}
    'title':
    {'help': 'title of to-do', 'action': 'store'}
    '-c|--description':
    {'help': 'description of to-do', 'action': 'store', 'default': ''}
    '-d|--due-date':
    {'help': 'due date for the to-do', 'action': 'store', 'default': None}
'update|user|email':
    'callback':
    <function update_user_email at 0x7f11d6fcfdc0>
    'name':
    {'help': 'user name', 'action': 'store'}
    'email':
    {'help': 'user email', 'action': 'store'}
'update|user|phone':
    'callback':
    <function update_user_phone at 0x7f11d6fcfe50>
    'name':
    {'help': 'user name', 'action': 'store'}
    'phone':
    {'help': 'user phone', 'action': 'store'}
'update|todo|title':
    'callback':
    <function update_todo_title at 0x7f11d6fcfee0>
    'id':
    {'help': 'ID of to-do', 'action': 'store'}
    'title':
    {'help': 'title of to-do', 'action': 'store'}
'update|todo|description':
    'callback':
    <function update_todo_description at 0x7f11d6fcff70>
    'id':
    {'help': 'ID of to-do', 'action': 'store'}
    'description':
    {'help': 'description of to-do', 'action': 'store'}
\end{verbatim}

We can generate a tree view of the CLI design specified by the above \texttt{dict},
namely \texttt{view}, as follows:
\begin{minted}[frame=single,fontsize=\scriptsize,linenos,bgcolor=lightblue,mathescape=true]{python}
from parsearg.parser import ParseArg

print(
    ParseArg(d=view, root_name='TODO').tree.show(quiet=True)
)
\end{minted}

\begin{verbatim}
TODO
    purge
        todos
        users
    update
        user
            phone
            email
        todo
            description
            title
    show
        todos
        users
    create
        user
        todo
\end{verbatim}

\section{How \texttt{parsearg} works}
\label{sec:org1f4197a}
It is easier to explain how \texttt{parsearg} works with a simpler abstraction 
than the above example \texttt{parsearg.examples.todos.py}. Here, we will 
consider nested parsers as trees. We introduce two trees for this purpose:
\begin{enumerate}
\item The ``A tree'', and
\item The ``A-AA tree''.
\end{enumerate}

\subsection{The A-tree}
\label{sec:org7d076ad}
The ``A tree'' has three levels. As each node of the tree must
necessarily occupy a positional argument of the command line,
\texttt{[-f]} and \texttt{[-g]} are correspondingly \emph{optional arguments} that attach to the nodes 
(\texttt{A} and \texttt{BB}, respectively, in the below diagram). 
\begin{center}
\includegraphics[width=0.5\linewidth]{./img/tree-abc-a.png}
\end{center}

Let's look at the Python code for \href{https://github.com/tharte/parsearg/blob/master/parsearg/examples/a.py}{\texttt{a.py}}.

Consider the \texttt{dict} that represents the View component:
\begin{minted}[frame=single,fontsize=\scriptsize,linenos,bgcolor=lightblue,mathescape=true]{python}
from parsearg.examples.a import view

show(view)
\end{minted}

\begin{verbatim}
'A':
    'callback':
    <function make_callback.<locals>.func at 0x7f11d7d10c10>
    '-c':
    {'help': 'A [optional pi]', 'action': 'store_const', 'const': 3.141593}
    '-v|--verbose':
    {'help': 'A verbosity', 'action': 'store_true'}
'A|B':
    'callback':
    <function make_callback.<locals>.func at 0x7f11d70409d0>
    '-c':
    {'help': 'A B [optional pi]', 'action': 'store_const', 'const': 3.141593}
    '-v|--verbose':
    {'help': 'A B verbosity', 'action': 'store_true'}
'A|BB':
    'callback':
    <function make_callback.<locals>.func at 0x7f11d7040a60>
    '-c':
    {'help': 'A BB [optional pi]', 'action': 'store_const', 'const': 3.141593}
    '-v|--verbose':
    {'help': 'A BB erbosity', 'action': 'store_true'}
'A|BB|C':
    'callback':
    <function make_callback.<locals>.func at 0x7f11d7040af0>
    '-c':
    {'help': 'A BB C [optional pi]', 'action': 'store_const', 'const': 3.141593}
    '-v|--verbose':
    {'help': 'A BB C verbosity', 'action': 'store_true'}
'A|BB|CC':
    'callback':
    <function make_callback.<locals>.func at 0x7f11d7040b80>
    '-c':
    {'help': 'A BB CC [optional pi]', 'action': 'store_const', 'const': 3.141593}
    '-v|--verbose':
    {'help': 'A BB CC verbosity', 'action': 'store_true'}
'A|BB|CCC':
    'callback':
    <function make_callback.<locals>.func at 0x7f11d7040c10>
    '-c':
    {'help': 'A BB CCC [optional pi]', 'action': 'store_const', 'const': 3.141593}
    '-v|--verbose':
    {'help': 'A BB CCC verbosity', 'action': 'store_true'}
'A|BBB':
    'callback':
    <function make_callback.<locals>.func at 0x7f11d7040ca0>
    '-c':
    {'help': 'A BBB [optional pi]', 'action': 'store_const', 'const': 3.141593}
    '-v|--verbose':
    {'help': 'A BBB verbosity', 'action': 'store_true'}
\end{verbatim}
and then the tree that the parsed \texttt{dict} is represented by:
\begin{minted}[frame=single,fontsize=\scriptsize,linenos,bgcolor=lightblue,mathescape=true]{python}
print(
    ParseArg(d=view, root_name='TODO').tree.show(quiet=True)
)
\end{minted}

\begin{verbatim}
TODO
    A
        B
        BBB
        BB
            C
            CC
            CCC
\end{verbatim}

\subsection{The A-A tree}
\label{sec:org848a47b}
The A-AA tree simply extends the A tree one level:
\begin{center}
\includegraphics[width=1.0\linewidth]{./img/tree-abc-a-aa.png}
\end{center}

Let's look at the Python code for \href{https://github.com/tharte/parsearg/blob/master/parsearg/examples/a\_aa.py}{\texttt{a\_aa.py}}.

Consider the \texttt{dict} that represents the View component:
\begin{minted}[frame=single,fontsize=\scriptsize,linenos,bgcolor=lightblue,mathescape=true]{python}
from parsearg.examples.a_aa import view

show(view)
\end{minted}

\begin{verbatim}
'A':
    'callback':
    <function make_callback.<locals>.func at 0x7f11d7044670>
    '-c':
    {'help': 'A [optional pi]', 'action': 'store_const', 'const': 3.141593}
    '-v|--verbose':
    {'help': 'A verbosity', 'action': 'store_true'}
'A|B':
    'callback':
    <function make_callback.<locals>.func at 0x7f11d70445e0>
    '-c':
    {'help': 'A B [optional pi]', 'action': 'store_const', 'const': 3.141593}
    '-v|--verbose':
    {'help': 'A B verbosity', 'action': 'store_true'}
'A|BB':
    'callback':
    <function make_callback.<locals>.func at 0x7f11d7044550>
    '-c':
    {'help': 'A BB [optional pi]', 'action': 'store_const', 'const': 3.141593}
    '-v|--verbose':
    {'help': 'A BB erbosity', 'action': 'store_true'}
'A|BB|C':
    'callback':
    <function make_callback.<locals>.func at 0x7f11d70444c0>
    '-c':
    {'help': 'A BB C [optional pi]', 'action': 'store_const', 'const': 3.141593}
    '-v|--verbose':
    {'help': 'A BB C verbosity', 'action': 'store_true'}
'A|BB|CC':
    'callback':
    <function make_callback.<locals>.func at 0x7f11d7044430>
    '-c':
    {'help': 'A BB CC [optional pi]', 'action': 'store_const', 'const': 3.141593}
    '-v|--verbose':
    {'help': 'A BB CC verbosity', 'action': 'store_true'}
'A|BB|CCC':
    'callback':
    <function make_callback.<locals>.func at 0x7f11d70443a0>
    '-c':
    {'help': 'A BB CCC [optional pi]', 'action': 'store_const', 'const': 3.141593}
    '-v|--verbose':
    {'help': 'A BB CCC verbosity', 'action': 'store_true'}
'A|BBB':
    'callback':
    <function make_callback.<locals>.func at 0x7f11d70440d0>
    '-c':
    {'help': 'A BBB [optional pi]', 'action': 'store_const', 'const': 3.141593}
    '-v|--verbose':
    {'help': 'A BBB verbosity', 'action': 'store_true'}
'AA':
    'callback':
    <function make_callback.<locals>.func at 0x7f11d7044310>
    '-c':
    {'help': 'AA [optional pi]', 'action': 'store_const', 'const': 3.141593}
    '-v|--verbose':
    {'help': 'AA verbosity', 'action': 'store_true'}
'AA|B':
    'callback':
    <function make_callback.<locals>.func at 0x7f11d7044280>
    '-c':
    {'help': 'AA B [optional pi]', 'action': 'store_const', 'const': 3.141593}
    '-v|--verbose':
    {'help': 'AA B verbosity', 'action': 'store_true'}
'AA|BB':
    'callback':
    <function make_callback.<locals>.func at 0x7f11d70441f0>
    '-c':
    {'help': 'AA BB [optional pi]', 'action': 'store_const', 'const': 3.141593}
    '-v|--verbose':
    {'help': 'AA BB verbosity', 'action': 'store_true'}
'AA|BB|C':
    'callback':
    <function make_callback.<locals>.func at 0x7f11d7044160>
    '-c':
    {'help': 'AA BB C [optional pi]', 'action': 'store_const', 'const': 3.141593}
    '-v|--verbose':
    {'help': 'AA BB C verbosity', 'action': 'store_true'}
'AA|BB|CC':
    'callback':
    <function make_callback.<locals>.func at 0x7f11d7044040>
    '-c':
    {'help': 'AA BB CC [optional pi]', 'action': 'store_const', 'const': 3.141593}
    '-v|--verbose':
    {'help': 'AA BB CC verbosity', 'action': 'store_true'}
'AA|BB|CCC':
    'callback':
    <function make_callback.<locals>.func at 0x7f11d7044c10>
    '-c':
    {'help': 'AA BB CCC [optional pi]', 'action': 'store_const', 'const': 3.141593}
    '-v|--verbose':
    {'help': 'AA BB CCC verbosity', 'action': 'store_true'}
'AA|BBB':
    'callback':
    <function make_callback.<locals>.func at 0x7f11d7044ca0>
    '-c':
    {'help': 'AA BBB [optional pi]', 'action': 'store_const', 'const': 3.141593}
    '-v|--verbose':
    {'help': 'AA BBB verbosity', 'action': 'store_true'}
\end{verbatim}
and then the tree that the parsed \texttt{dict} is represented by:
\begin{minted}[frame=single,fontsize=\scriptsize,linenos,bgcolor=lightblue,mathescape=true]{python}
print(
    ParseArg(d=view, root_name='TODO').tree.show(quiet=True)
)
\end{minted}

\begin{verbatim}
TODO
    AA
        B
        BBB
        BB
            C
            CC
            CCC
    A
        B
        BBB
        BB
            C
            CC
            CCC
\end{verbatim}


We can now run the A-tree and the A-AA-tree examples, respectively:
\begin{minted}[frame=single,fontsize=\scriptsize,linenos,bgcolor=lightblue,mathescape=true]{python}
from parsearg.examples.a import main
main()
\end{minted}

\begin{verbatim}
NODE :: 'A':
--------------
usage:  A [-h] [-c] [-v] {B,BBB,BB} ...

positional arguments:
  {B,BBB,BB}

optional arguments:
  -h, --help     show this help message and exit
  -c             A [optional pi]
  -v, --verbose  A verbosity


'A':
----
	args: {'c': None, 'verbose': False}
	<Mock name='mock.A' id='139714611964512'>
'A -v':
-------
	args: {'c': None, 'verbose': True}
	<Mock name='mock.A' id='139714611964512'>
'A -c':
-------
	args: {'c': 3.141593, 'verbose': False}
	<Mock name='mock.A' id='139714611964512'>
'A -v -c':
----------
	args: {'c': 3.141593, 'verbose': True}
	<Mock name='mock.A' id='139714611964512'>


NODE :: 'A B':
----------------
usage: A B [-h] [-c] [-v]

optional arguments:
  -h, --help     show this help message and exit
  -c             A B [optional pi]
  -v, --verbose  A B verbosity


'A B':
------
	args: {'c': None, 'verbose': False}
	<Mock name='mock.A_B' id='139714598437792'>
'A B -v':
---------
	args: {'c': None, 'verbose': True}
	<Mock name='mock.A_B' id='139714598437792'>
'A B -c':
---------
	args: {'c': 3.141593, 'verbose': False}
	<Mock name='mock.A_B' id='139714598437792'>
'A B -v -c':
------------
	args: {'c': 3.141593, 'verbose': True}
	<Mock name='mock.A_B' id='139714598437792'>


NODE :: 'A BB':
-----------------
usage: A BB [-h] [-c] [-v] {C,CC,CCC} ...

positional arguments:
  {C,CC,CCC}

optional arguments:
  -h, --help     show this help message and exit
  -c             A BB [optional pi]
  -v, --verbose  A BB erbosity


'A BB':
-------
	args: {'c': None, 'verbose': False}
	<Mock name='mock.A_BB' id='139714598483088'>
'A BB -v':
----------
	args: {'c': None, 'verbose': True}
	<Mock name='mock.A_BB' id='139714598483088'>
'A BB -c':
----------
	args: {'c': 3.141593, 'verbose': False}
	<Mock name='mock.A_BB' id='139714598483088'>
'A BB -v -c':
-------------
	args: {'c': 3.141593, 'verbose': True}
	<Mock name='mock.A_BB' id='139714598483088'>


NODE :: 'A BB C':
-------------------
usage: A BB C [-h] [-c] [-v]

optional arguments:
  -h, --help     show this help message and exit
  -c             A BB C [optional pi]
  -v, --verbose  A BB C verbosity


'A BB C':
---------
	args: {'c': None, 'verbose': False}
	<Mock name='mock.A_BB_C' id='139714598483280'>
'A BB C -v':
------------
	args: {'c': None, 'verbose': True}
	<Mock name='mock.A_BB_C' id='139714598483280'>
'A BB C -c':
------------
	args: {'c': 3.141593, 'verbose': False}
	<Mock name='mock.A_BB_C' id='139714598483280'>
'A BB C -v -c':
---------------
	args: {'c': 3.141593, 'verbose': True}
	<Mock name='mock.A_BB_C' id='139714598483280'>


NODE :: 'A BB CC':
--------------------
usage: A BB CC [-h] [-c] [-v]

optional arguments:
  -h, --help     show this help message and exit
  -c             A BB CC [optional pi]
  -v, --verbose  A BB CC verbosity


'A BB CC':
----------
	args: {'c': None, 'verbose': False}
	<Mock name='mock.A_BB_CC' id='139714598483472'>
'A BB CC -v':
-------------
	args: {'c': None, 'verbose': True}
	<Mock name='mock.A_BB_CC' id='139714598483472'>
'A BB CC -c':
-------------
	args: {'c': 3.141593, 'verbose': False}
	<Mock name='mock.A_BB_CC' id='139714598483472'>
'A BB CC -v -c':
----------------
	args: {'c': 3.141593, 'verbose': True}
	<Mock name='mock.A_BB_CC' id='139714598483472'>


NODE :: 'A BB CCC':
---------------------
usage: A BB CCC [-h] [-c] [-v]

optional arguments:
  -h, --help     show this help message and exit
  -c             A BB CCC [optional pi]
  -v, --verbose  A BB CCC verbosity


'A BB CCC':
-----------
	args: {'c': None, 'verbose': False}
	<Mock name='mock.A_BB_CCC' id='139714598483664'>
'A BB CCC -v':
--------------
	args: {'c': None, 'verbose': True}
	<Mock name='mock.A_BB_CCC' id='139714598483664'>
'A BB CCC -c':
--------------
	args: {'c': 3.141593, 'verbose': False}
	<Mock name='mock.A_BB_CCC' id='139714598483664'>
'A BB CCC -v -c':
-----------------
	args: {'c': 3.141593, 'verbose': True}
	<Mock name='mock.A_BB_CCC' id='139714598483664'>
\end{verbatim}

\begin{minted}[frame=single,fontsize=\scriptsize,linenos,bgcolor=lightblue,mathescape=true]{python}
from parsearg.examples.a_aa import main
main()
\end{minted}

\begin{verbatim}
NODE :: 'A':
--------------
usage:  A [-h] [-c] [-v] {B,BBB,BB} ...

positional arguments:
  {B,BBB,BB}

optional arguments:
  -h, --help     show this help message and exit
  -c             A [optional pi]
  -v, --verbose  A verbosity


'A':
----
	args: {'c': None, 'verbose': False}
	<Mock name='mock.A' id='139714598483904'>
'A -v':
-------
	args: {'c': None, 'verbose': True}
	<Mock name='mock.A' id='139714598483904'>
'A -c':
-------
	args: {'c': 3.141593, 'verbose': False}
	<Mock name='mock.A' id='139714598483904'>
'A -v -c':
----------
	args: {'c': 3.141593, 'verbose': True}
	<Mock name='mock.A' id='139714598483904'>


NODE :: 'A B':
----------------
usage: A B [-h] [-c] [-v]

optional arguments:
  -h, --help     show this help message and exit
  -c             A B [optional pi]
  -v, --verbose  A B verbosity


'A B':
------
	args: {'c': None, 'verbose': False}
	<Mock name='mock.A_B' id='139714598562448'>
'A B -v':
---------
	args: {'c': None, 'verbose': True}
	<Mock name='mock.A_B' id='139714598562448'>
'A B -c':
---------
	args: {'c': 3.141593, 'verbose': False}
	<Mock name='mock.A_B' id='139714598562448'>
'A B -v -c':
------------
	args: {'c': 3.141593, 'verbose': True}
	<Mock name='mock.A_B' id='139714598562448'>


NODE :: 'A BB':
-----------------
usage: A BB [-h] [-c] [-v] {C,CC,CCC} ...

positional arguments:
  {C,CC,CCC}

optional arguments:
  -h, --help     show this help message and exit
  -c             A BB [optional pi]
  -v, --verbose  A BB erbosity


'A BB':
-------
	args: {'c': None, 'verbose': False}
	<Mock name='mock.A_BB' id='139714598562592'>
'A BB -v':
----------
	args: {'c': None, 'verbose': True}
	<Mock name='mock.A_BB' id='139714598562592'>
'A BB -c':
----------
	args: {'c': 3.141593, 'verbose': False}
	<Mock name='mock.A_BB' id='139714598562592'>
'A BB -v -c':
-------------
	args: {'c': 3.141593, 'verbose': True}
	<Mock name='mock.A_BB' id='139714598562592'>


NODE :: 'A BB C':
-------------------
usage: A BB C [-h] [-c] [-v]

optional arguments:
  -h, --help     show this help message and exit
  -c             A BB C [optional pi]
  -v, --verbose  A BB C verbosity


'A BB C':
---------
	args: {'c': None, 'verbose': False}
	<Mock name='mock.A_BB_C' id='139714598562256'>
'A BB C -v':
------------
	args: {'c': None, 'verbose': True}
	<Mock name='mock.A_BB_C' id='139714598562256'>
'A BB C -c':
------------
	args: {'c': 3.141593, 'verbose': False}
	<Mock name='mock.A_BB_C' id='139714598562256'>
'A BB C -v -c':
---------------
	args: {'c': 3.141593, 'verbose': True}
	<Mock name='mock.A_BB_C' id='139714598562256'>


NODE :: 'A BB CC':
--------------------
usage: A BB CC [-h] [-c] [-v]

optional arguments:
  -h, --help     show this help message and exit
  -c             A BB CC [optional pi]
  -v, --verbose  A BB CC verbosity


'A BB CC':
----------
	args: {'c': None, 'verbose': False}
	<Mock name='mock.A_BB_CC' id='139714598562496'>
'A BB CC -v':
-------------
	args: {'c': None, 'verbose': True}
	<Mock name='mock.A_BB_CC' id='139714598562496'>
'A BB CC -c':
-------------
	args: {'c': 3.141593, 'verbose': False}
	<Mock name='mock.A_BB_CC' id='139714598562496'>
'A BB CC -v -c':
----------------
	args: {'c': 3.141593, 'verbose': True}
	<Mock name='mock.A_BB_CC' id='139714598562496'>


NODE :: 'A BB CCC':
---------------------
usage: A BB CCC [-h] [-c] [-v]

optional arguments:
  -h, --help     show this help message and exit
  -c             A BB CCC [optional pi]
  -v, --verbose  A BB CCC verbosity


'A BB CCC':
-----------
	args: {'c': None, 'verbose': False}
	<Mock name='mock.A_BB_CCC' id='139714598562016'>
'A BB CCC -v':
--------------
	args: {'c': None, 'verbose': True}
	<Mock name='mock.A_BB_CCC' id='139714598562016'>
'A BB CCC -c':
--------------
	args: {'c': 3.141593, 'verbose': False}
	<Mock name='mock.A_BB_CCC' id='139714598562016'>
'A BB CCC -v -c':
-----------------
	args: {'c': 3.141593, 'verbose': True}
	<Mock name='mock.A_BB_CCC' id='139714598562016'>


NODE :: 'AA':
---------------
usage:  AA [-h] [-c] [-v] {B,BBB,BB} ...

positional arguments:
  {B,BBB,BB}

optional arguments:
  -h, --help     show this help message and exit
  -c             AA [optional pi]
  -v, --verbose  AA verbosity


'AA':
-----
	args: {'c': None, 'verbose': False}
	<Mock name='mock.AA' id='139714598576960'>
'AA -v':
--------
	args: {'c': None, 'verbose': True}
	<Mock name='mock.AA' id='139714598576960'>
'AA -c':
--------
	args: {'c': 3.141593, 'verbose': False}
	<Mock name='mock.AA' id='139714598576960'>
'AA -v -c':
-----------
	args: {'c': 3.141593, 'verbose': True}
	<Mock name='mock.AA' id='139714598576960'>


NODE :: 'AA B':
-----------------
usage: AA B [-h] [-c] [-v]

optional arguments:
  -h, --help     show this help message and exit
  -c             AA B [optional pi]
  -v, --verbose  AA B verbosity


'AA B':
-------
	args: {'c': None, 'verbose': False}
	<Mock name='mock.AA_B' id='139714598576912'>
'AA B -v':
----------
	args: {'c': None, 'verbose': True}
	<Mock name='mock.AA_B' id='139714598576912'>
'AA B -c':
----------
	args: {'c': 3.141593, 'verbose': False}
	<Mock name='mock.AA_B' id='139714598576912'>
'AA B -v -c':
-------------
	args: {'c': 3.141593, 'verbose': True}
	<Mock name='mock.AA_B' id='139714598576912'>


NODE :: 'AA BB':
------------------
usage: AA BB [-h] [-c] [-v] {C,CC,CCC} ...

positional arguments:
  {C,CC,CCC}

optional arguments:
  -h, --help     show this help message and exit
  -c             AA BB [optional pi]
  -v, --verbose  AA BB verbosity


'AA BB':
--------
	args: {'c': None, 'verbose': False}
	<Mock name='mock.AA_BB' id='139714598576864'>
'AA BB -v':
-----------
	args: {'c': None, 'verbose': True}
	<Mock name='mock.AA_BB' id='139714598576864'>
'AA BB -c':
-----------
	args: {'c': 3.141593, 'verbose': False}
	<Mock name='mock.AA_BB' id='139714598576864'>
'AA BB -v -c':
--------------
	args: {'c': 3.141593, 'verbose': True}
	<Mock name='mock.AA_BB' id='139714598576864'>


NODE :: 'AA BB C':
--------------------
usage: AA BB C [-h] [-c] [-v]

optional arguments:
  -h, --help     show this help message and exit
  -c             AA BB C [optional pi]
  -v, --verbose  AA BB C verbosity


'AA BB C':
----------
	args: {'c': None, 'verbose': False}
	<Mock name='mock.AA_BB_C' id='139714598577824'>
'AA BB C -v':
-------------
	args: {'c': None, 'verbose': True}
	<Mock name='mock.AA_BB_C' id='139714598577824'>
'AA BB C -c':
-------------
	args: {'c': 3.141593, 'verbose': False}
	<Mock name='mock.AA_BB_C' id='139714598577824'>
'AA BB C -v -c':
----------------
	args: {'c': 3.141593, 'verbose': True}
	<Mock name='mock.AA_BB_C' id='139714598577824'>


NODE :: 'AA BB CC':
---------------------
usage: AA BB CC [-h] [-c] [-v]

optional arguments:
  -h, --help     show this help message and exit
  -c             AA BB CC [optional pi]
  -v, --verbose  AA BB CC verbosity


'AA BB CC':
-----------
	args: {'c': None, 'verbose': False}
	<Mock name='mock.AA_BB_CC' id='139714598577536'>
'AA BB CC -v':
--------------
	args: {'c': None, 'verbose': True}
	<Mock name='mock.AA_BB_CC' id='139714598577536'>
'AA BB CC -c':
--------------
	args: {'c': 3.141593, 'verbose': False}
	<Mock name='mock.AA_BB_CC' id='139714598577536'>
'AA BB CC -v -c':
-----------------
	args: {'c': 3.141593, 'verbose': True}
	<Mock name='mock.AA_BB_CC' id='139714598577536'>


NODE :: 'AA BB CCC':
----------------------
usage: AA BB CCC [-h] [-c] [-v]

optional arguments:
  -h, --help     show this help message and exit
  -c             AA BB CCC [optional pi]
  -v, --verbose  AA BB CCC verbosity


'AA BB CCC':
------------
	args: {'c': None, 'verbose': False}
	<Mock name='mock.AA_BB_CCC' id='139714598576384'>
'AA BB CCC -v':
---------------
	args: {'c': None, 'verbose': True}
	<Mock name='mock.AA_BB_CCC' id='139714598576384'>
'AA BB CCC -c':
---------------
	args: {'c': 3.141593, 'verbose': False}
	<Mock name='mock.AA_BB_CCC' id='139714598576384'>
'AA BB CCC -v -c':
------------------
	args: {'c': 3.141593, 'verbose': True}
	<Mock name='mock.AA_BB_CCC' id='139714598576384'>
\end{verbatim}
\end{document}
