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

declares semantics of a command More...

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

Classes

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

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

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

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

Member Function Documentation

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

Parameters
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.

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

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

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

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

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

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

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

parse a command line

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

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

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

set one-line description

Parameters
titleone-line description, written in lower case

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