parses a command More...
#include <tools/nfdc/command-parser.hpp>
Classes | |
class | Error |
Public Member Functions | |
CommandParser & | addAlias (const std::string &noun, const std::string &verb, const std::string &verb2) |
add an alias "noun verb2" to existing command "noun verb" More... | |
CommandParser & | addCommand (const CommandDefinition &def, const ExecuteCommand &execute, std::underlying_type< AvailableIn >::type modes=AVAILABLE_IN_ALL) |
add an available command More... | |
std::vector< const CommandDefinition * > | listCommands (const std::string &noun, ParseMode mode) const |
list known commands for help More... | |
std::tuple< std::string, std::string, CommandArguments, ExecuteCommand > | parse (const std::vector< std::string > &tokens, ParseMode mode) const |
parse a command line More... | |
parses a command
Definition at line 62 of file command-parser.hpp.
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"
std::out_of_range | "noun verb" does not exist |
Definition at line 88 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
def | command semantics definition |
execute | a function to execute the command |
modes | parse modes this command should be available in, must not be AVAILABLE_IN_NONE |
Definition at line 73 of file command-parser.cpp.
std::vector< const CommandDefinition * > nfd::tools::nfdc::CommandParser::listCommands | ( | const std::string & | noun, |
ParseMode | mode | ||
) | const |
list known commands for help
noun | if not empty, filter results by this noun |
mode | include commands for the specified parse mode |
Definition at line 95 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
tokens | command line |
mode | parser mode, must be ParseMode::ONE_SHOT, other modes are not implemented |
Error | command is not found |
CommandDefinition::Error | command arguments are invalid |
Definition at line 109 of file command-parser.cpp.