61 GetOpt(
const Arg & arg ,
const std::string & spec , std::size_t ignore_non_options = 0U ) ;
65 GetOpt(
const StringArray & arg ,
const std::string & spec , std::size_t ignore_non_options = 0U ) ;
70 GetOpt(
const Arg & arg ,
const Options & spec , std::size_t ignore_non_options = 0U ) ;
81 const std::string & varkey = {} ,
const std::string & varvalue = {} ) ;
100 const std::vector<Option> &
options()
const ;
115 void showErrors( std::ostream & stream ,
const std::string & prefix_1 ,
116 const std::string & prefix_2 = std::string(
": ") )
const ;
121 void showErrors( std::ostream & stream )
const ;
124 bool contains(
char option_letter )
const ;
128 bool contains( std::string_view option_name )
const ;
132 std::size_t
count( std::string_view option_name )
const ;
135 std::string
value( std::string_view option_name , std::string_view default_ = {} )
const ;
142 std::string
value(
char option_letter , std::string_view default_ = {} )
const ;
152 void parseArgs( std::size_t ) ;
A class which holds a represention of the argc/argv command line array, and supports simple command-l...
A command-line option parser.
const OptionMap & map() const
Exposes the map of option-values.
void reload(const StringArray &arg, std::size_t ignore_non_options=0U)
Reinitialises the object with the given command-line arguments.
bool contains(char option_letter) const
Returns true if the command-line contains the option identified by its short-form letter.
const std::vector< Option > & options() const
Exposes the list of option specification objects.
GetOpt(const Arg &arg, const std::string &spec, std::size_t ignore_non_options=0U)
Constructor taking a Arg object and a G::Options specification string.
std::string value(std::string_view option_name, std::string_view default_={}) const
Returns the value for the option identified by its long-form name.
static StringArray readOptionsFromFile(const Path &)
Reads options from file as a list of strings like "--foo=bar".
bool hasErrors() const
Returns true if there are errors.
std::size_t count(std::string_view option_name) const
Returns the option's repeat count.
void addOptionsFromFile(std::size_t n=1U, const std::string &varkey={}, const std::string &varvalue={})
Adds options from the config file named by the n'th non-option command-line argument (zero-based and ...
bool addOptionsFromFile(size_t n, const StringArray &extension_blocklist)
Adds options from the config file named by the n'th non-option argument, but not if the file extensio...
Arg args() const
Returns the G::Arg command-line, excluding options.
void showErrors(std::ostream &stream, const std::string &prefix_1, const std::string &prefix_2=std::string(": ")) const
A convenience function which streams out each errorList() item to the given stream,...
StringArray errorList() const
Returns the list of errors.
A multimap-like container for command-line options and their values.
A class to assemble a list of command-line options and provide access by name.
A Path object represents a file system path.
std::vector< std::string > StringArray
A std::vector of std::strings.