Command Line Interface

The CommandLineInterpreter makes working with input parameters easier. With it, we get access to command line arguments that are entered in the form:

./example name=abc


We start by importing the necessary interfaces and establish the service factory.

#include "include/commandline/factory_cli.h"
#include "include/commandline/commandline_interface.h"

int main( int argc, char** argv )
CommandLineInterpreterFactory cli_factory;
CommandLineInterface *cli = cli_factory.get_command_line_interface( argc, argv );

We can utilize get_program_name to return the current program name executing on this instance.

std::cout << cli->get_program_name() << std::endl;

We have access to an opt_exist method to determine if an option was entered, and we can use get_opt to pull parameter values.

if ( cli->opt_exist("name") ) {
  std::cout << cli->get_opt("name") << std::endl;

return 0;


The Command Line Interpreter is threadsafe, and it is recommended that you utilize a single interpreter and have each thread access the arguments in it, to ensure that the input parameters are only parsed once.

Go Home