nfd::tools::nfdc::CommandDefinition Class Reference

declares semantics of a command More...

#include <tools/nfdc/command-definition.hpp>


class  Error

Public Member Functions

 CommandDefinition (const std::string &noun, const std::string &verb)
 ~CommandDefinition ()
CommandDefinitionaddArg (const std::string &name, ArgValueType valueType, Required isRequired=Required::NO, Positional allowPositional=Positional::NO, const std::string &metavar="")
 declare an argument More...
const std::string getNoun () const
const std::string & getTitle () const
const std::string getVerb () const
CommandArguments parse (const std::vector< std::string > &tokens, size_t start=0) const
 parse a command line More...
CommandDefinitionsetTitle (const std::string &title)
 set one-line description More...

Detailed Description

declares semantics of a command

Definition at line 127 of file command-definition.hpp.

Constructor & Destructor Documentation

◆ CommandDefinition()

nfd::tools::nfdc::CommandDefinition::CommandDefinition ( const std::string &  noun,
const std::string &  verb 

Definition at line 96 of file command-definition.cpp.

◆ ~CommandDefinition()

nfd::tools::nfdc::CommandDefinition::~CommandDefinition ( )

Member Function Documentation

◆ addArg()

CommandDefinition & nfd::tools::nfdc::CommandDefinition::addArg ( const std::string &  name,
ArgValueType  valueType,
Required  isRequired = Required::NO,
Positional  allowPositional = Positional::NO,
const std::string &  metavar = "" 

declare an argument

nameargument name, must be unique
valueTypeargument value type
isRequiredwhether the argument is required
allowPositionalwhether the argument value can be specified as positional
metavardisplayed argument value placeholder

Definition at line 105 of file command-definition.cpp.

◆ getNoun()

const std::string nfd::tools::nfdc::CommandDefinition::getNoun ( ) const

Definition at line 141 of file command-definition.hpp.

◆ getTitle()

const std::string& nfd::tools::nfdc::CommandDefinition::getTitle ( ) const
one-line description

Definition at line 156 of file command-definition.hpp.

◆ getVerb()

const std::string nfd::tools::nfdc::CommandDefinition::getVerb ( ) const

Definition at line 147 of file command-definition.hpp.

◆ parse()

CommandArguments nfd::tools::nfdc::CommandDefinition::parse ( const std::vector< std::string > &  tokens,
size_t  start = 0 
) const

parse a command line

tokenscommand line tokens
startcommand line start position, after noun and verb
Errorcommand line is invalid

Definition at line 130 of file command-definition.cpp.

◆ setTitle()

CommandDefinition& nfd::tools::nfdc::CommandDefinition::setTitle ( const std::string &  title)

set one-line description

titleone-line description, written in lower case

Definition at line 165 of file command-definition.hpp.