The ChopStiX toolchain implements a git-like command line toolchain, where you run 'chop ' to access the different functionalities.
Each command is implemented in the src/client
directory and depends on two files:
src/client/usage/<command>
src/client/<command>.cpp
It also has to be added to src/client/CMakeLists.txt
.
src/client/usage/<command>
contains the help/usage for the command. It
transpiled in order to generate a parser for this command. Parameters and flags
are automatically detected whenever a line in the usage starts with two
space and a -
.
All options and flags must start with a single -
. Options have either an
argument in the form of -opt <arg>
) or are binary flags that can be
enabled/disabled with -feature
/-no-feature
respectively. The default value
can be specified with (default: some value)
, otherwise it is equal to NULL
.
Internally options are saved via corresponding environment variables, which
makes them accessible throughout the codebase. The corresponding environment
variable for the option foo
is CHOPSTIX_OPT_FOO
. Options can be interpreted
as integers, floats, strings, booleans and time values, as well as lists of all
these types.
src/client/<command>.cpp
must implement int run_<command>(int,char**)
,
which will be called from main
. The PARSE_OPTIONS(Argc, Argv, Command)
macro implements the option parser for this command.
All options can be passed using environment variables. Command line specifiers takes preference over the environment defined settings.