cli#
-
namespace heph
-
namespace cli#
-
class ProgramDescription#
- #include “hephaestus/cli/program_options.h”
Program description and command line parsing utility. Works with ProgramOptions class.
Features:
Enforces that every supported command line option is described exactly once
Throws if unsupported options are specified on the command line
Throws if required options are not specified on the command line
Throws if value types are mismatched between where they are defined and where they are used
Ensures ‘help’ is always available See also ProgramOptions
Public Functions
-
explicit ProgramDescription(std::string brief)#
Creates object.
- Parameters:
brief – A brief text describing the program
-
template<StringStreamable T>
ProgramDescription &defineOption(const std::string &key, const std::string &description)# Defines a required option (—key=value) on the command line.
- Template Parameters:
T – Value type
- Parameters:
key – Key of the key-value pair
description – A brief text describing the option
- Returns:
Reference to the object. Enables daisy-chained calls
-
template<StringStreamable T>
ProgramDescription &defineOption(const std::string &key, char short_key, const std::string &description)# Defines a required option (—key=value) on the command line.
- Template Parameters:
T – Value type
- Parameters:
key – Key of the key-value pair
short_key – Single char (can be used as alias for —key)
description – A brief text describing the option
- Returns:
Reference to the object. Enables daisy-chained calls
-
template<StringStreamable T>
ProgramDescription &defineOption(const std::string &key, const std::string &description, const T &default_value)# Defines a command line option (—key=value) that is optional.
- Template Parameters:
T – Value type
- Parameters:
key – Key of the key-value pair
description – A brief text describing the option
default_value – Default value to use if the option is not specified on the command line
- Returns:
Reference to the object. Enables daisy-chained calls
-
template<StringStreamable T>
ProgramDescription &defineOption(const std::string &key, char short_key, const std::string &description, const T &default_value)# Defines a command line option (—key=value) that is optional.
- Template Parameters:
T – Value type
- Parameters:
key – Key of the key-value pair
short_key – Single char (can be used as alias for —key)
description – A brief text describing the option
default_value – Default value to use if the option is not specified on the command line
- Returns:
Reference to the object. Enables daisy-chained calls
-
ProgramDescription &defineFlag(const std::string &key, char short_key, const std::string &description)#
Defines a boolean option (flag) (—key=value) on the command line. If the flag is passed the value of the option is true, false otherwise.
- Parameters:
key – Key of the key-value pair
short_key – Single char (can be used as alias for —key)
description – A brief text describing the option
- Returns:
Reference to the object. Enables daisy-chained calls
-
ProgramDescription &defineFlag(const std::string &key, const std::string &description)#
Defines a boolean option (flag) (—key=value) on the command line. If the flag is passed the value of the option is true, false otherwise.
- Parameters:
key – Key of the key-value pair
description – A brief text describing the option
- Returns:
Reference to the object. Enables daisy-chained calls
-
ProgramOptions parse(int argc, const char **argv) &&#
Builds the container to parse command line options.
Note
: The resources in this object is moved into the returned object, making this object invalid.
- Parameters:
argc – Number of arguments on the command line
argv – array of C-style strings
- Returns:
Object containing command line options
-
ProgramOptions parse(const std::vector<std::string> &args) &&#
Builds the container to parse command line options.
Note
: The resources in this object is moved into the returned object, making this object invalid.
- Parameters:
args – List of element passed to the program
- Returns:
Object containing command line options
-
class ProgramOptions#
- #include “hephaestus/cli/program_options.h”
Container for command line options for a program. To be used with ProgramDescription class.
-
struct Option#
- #include “hephaestus/cli/program_options.h”
Holds program options and their details.
-
struct Option#
-
class ProgramDescription#
-
namespace cli#
-
namespace heph
-
namespace cli
-
namespace cli