\chapter{Appendix D}\label{appendix:cmdref}

\section{\iottb}\label{cmdref:iottb}
\begin{verbatim}
Usage: iottb [OPTIONS] COMMAND [ARGS]...

Options:
  -v, --verbosity  Set verbosity  [default: 0; 0<=x<=3]
  -d, --debug      Enable debug mode
  --dry-run        [default: True]
  --cfg-file PATH  Path to iottb config file  [default:
                   $HOME/.config/iottb/iottb.cfg]
  --help           Show this message and exit.

Commands:
  add-device           Add a device to a database
  init-db
  rm-cfg               Removes the cfg file from the filesystem.
  rm-dbs               Removes ALL(!) databases from the filesystem if...
  set-key-in-table-to  Edit config or metadata files.
  show-all             Show everything: configuration, databases, and...
  show-cfg             Show the current configuration context
  sniff                Sniff packets with tcpdump
\end{verbatim}

\subsection{Initialize Database}\label{cmdref:init-db}
\begin{verbatim}
Usage: iottb init-db [OPTIONS]

Options:
  -d, --dest PATH                 Location to put (new) iottb database
  -n, --name TEXT                 Name of new database.  [default: iottb.db]
  --update-default / --no-update-default
                                  If new db should be set as the new default
                                  [default: update-default]
  --help                          Show this message and exit.
\end{verbatim}

\subsection{Add device}\label{cmdref:add-device}
\begin{verbatim}
Usage: iottb add-device [OPTIONS]

  Add a device to a database

Options:
  --dev, --device-name TEXT   The name of the device to be added. If this
                              string contains spaces or other special
                              characters               normalization is
                              performed to derive a canonical name  [required]
  --db, --database DIRECTORY  Database in which to add this device. If not
                              specified use default from config.  [env var:
                              IOTTB_DB]
  --guided                    Add device interactively  [env var:
                              IOTTB_GUIDED_ADD]
  --help                      Show this message and exit.
\end{verbatim}

\subsection{Capture traffic with \textit{tcpdump}}\label{cmdref:sniff}
\begin{verbatim}
Usage: iottb sniff [OPTIONS] [TCPDUMP-ARGS] [DEVICE]

  Sniff packets with tcpdump

Options:
  Testbed sources: 
    --db, --database TEXT  Database of device. Only needed if not current
                           default.  [env var: IOTTB_DB]
    --app TEXT             Companion app being used during capture
  Runtime behaviour: 
    --unsafe               Disable checks for otherwise required options.
                           [env var: IOTTB_UNSAFE]
    --guided               [env var: IOTTB_GUIDED]
    --pre TEXT             Script to be executed before main  command is
                           started.
    --post TEXT            Script to be executed upon completion of main
                           command.
  Tcpdump options: 
    -i, --interface TEXT   Network interface to capture on.If not specified
                           tcpdump tries to find and appropriate one.  
                           [env var: IOTTB_CAPTURE_INTERFACE]
    -a, --address TEXT     IP or MAC address to filter packets by.  
                           [env var: IOTTB_CAPTURE_ADDRESS]
    -I, --monitor-mode     Put interface into monitor mode.
    --ff TEXT              tcpdump filter as string or file path.  
                           [env var: IOTTB_CAPTURE_FILTER]
    -#, --print-pacno      Print packet number at beginning of line. True by
                           default.  [default: True]
    -e, --print-ll         Print link layer headers. True by default.
    -c, --count INTEGER    Number of packets to capture.  [default: 1000]
  --help                   Show this message and exit.    
\end{verbatim}

\section{Utility commands}\label{cmdref:sec:utils}
Utility Commands mostly for development and have not yet been integrated into the standard workflow.
\subsection{Remove Configuration}\label{cmdref:rm-cfg}
\begin{verbatim}
Usage: iottb rm-cfg [OPTIONS]

  Removes the cfg file from the filesystem.

  This is mostly a utility during development. Once non-standard database
  locations are implemented, deleting this would lead to iottb not being able
  to find them anymore.

Options:
  --yes   Confirm the action without prompting.
  --help  Show this message and exit.   
\end{verbatim}

\subsection{Remove Database}\label{cmdref:rm-dbs}
\begin{verbatim}
Usage: iottb rm-dbs [OPTIONS]

  Removes ALL(!) databases from the filesystem if they're empty.

  Development utility currently unfit for use.

Options:
  --yes   Confirm the action without prompting.
  --help  Show this message and exit.    
\end{verbatim}

\subsection{Display Configuration File}\label{cmdref:show-cfg}
\begin{verbatim}
Usage: iottb show-cfg [OPTIONS]

  Show the current configuration context

Options:
  --cfg-file PATH  Path to the config file  [default:
                   /home/seb/.config/iottb/iottb.cfg]
  -pp              Pretty Print
  --help           Show this message and exit   
\end{verbatim}

\subsection{"Show All"}\label{cmdref:show-all}
\begin{verbatim}
Usage: iottb show-all [OPTIONS]

  Show everything: configuration, databases, and device metadata

Options:
  --help  Show this message and exit.    
\end{verbatim}

