nfd::tools::nfdc::CommandParser Class Reference

parses a command More...

#include <command-parser.hpp>

Inheritance diagram for nfd::tools::nfdc::CommandParser:
Collaboration diagram for nfd::tools::nfdc::CommandParser:

Classes

class  Error
 

Public Member Functions

CommandParseraddCommand (const CommandDefinition &def, const ExecuteCommand &execute, std::underlying_type< AvailableIn >::type modes=AVAILABLE_IN_ALL)
 add an available command More...
 
CommandParseraddAlias (const std::string &noun, const std::string &verb, const std::string &verb2)
 add an alias "noun verb2" to existing command "noun verb" More...
 
std::tuple< std::string, std::string, CommandArguments, ExecuteCommandparse (const std::vector< std::string > &tokens, ParseMode mode) const
 parse a command line More...
 

Detailed Description

parses a command

Definition at line 61 of file command-parser.hpp.

Member Function Documentation

CommandParser & nfd::tools::nfdc::CommandParser::addAlias ( const std::string &  noun,
const std::string &  verb,
const std::string &  verb2 
)

add an alias "noun verb2" to existing command "noun verb"

Exceptions
std::out_of_range"noun verb" does not exist

Definition at line 80 of file command-parser.cpp.

CommandParser & nfd::tools::nfdc::CommandParser::addCommand ( const CommandDefinition def,
const ExecuteCommand execute,
std::underlying_type< AvailableIn >::type  modes = AVAILABLE_IN_ALL 
)

add an available command

Parameters
defcommand semantics definition
executea function to execute the command
modesparse modes this command should be available in, must not be AVAILABLE_IN_NONE

Definition at line 70 of file command-parser.cpp.

std::tuple< std::string, std::string, CommandArguments, ExecuteCommand > nfd::tools::nfdc::CommandParser::parse ( const std::vector< std::string > &  tokens,
ParseMode  mode 
) const

parse a command line

Parameters
tokenscommand line
modeparser mode, must be ParseMode::ONE_SHOT, other modes are not implemented
Exceptions
Errorcommand is not found
CommandDefinition::Errorcommand arguments are invalid
Returns
noun, verb, arguments, execute function

Definition at line 87 of file command-parser.cpp.