CLI11  2.6.2
Namespaces | Classes | Typedefs | Enumerations | Functions | Variables
CLI Namespace Reference

Namespaces

 adl_detail
 
 detail
 
 enums
 
 FailureMessage
 

Classes

class  App
 Creates a command line program, with very few defaults. More...
 
class  ArgumentMismatch
 Thrown when the wrong number of arguments has been received. More...
 
class  AsNumberWithUnit
 
class  AsSizeValue
 
class  AutoTimer
 This class prints out the time upon destruction. More...
 
class  BadNameString
 Thrown on construction of a bad name. More...
 
class  Bound
 Produce a bounded range (factory). Min and max are inclusive. More...
 
class  CallForAllHelp
 Usually something like –help-all on command line. More...
 
class  CallForHelp
 -h or –help on command line More...
 
class  CallForVersion
 -v or –version on command line More...
 
class  CheckedTransformer
 translate named items to other or a value set More...
 
class  Config
 This class provides a converter for configuration files. More...
 
class  ConfigBase
 This converter works with INI/TOML files; to write INI files use ConfigINI. More...
 
class  ConfigError
 Thrown when extra values are found in an INI file. More...
 
class  ConfigINI
 ConfigINI generates a "standard" INI compliant output. More...
 
struct  ConfigItem
 Holds values to load into Options. More...
 
class  ConstructionError
 Construction errors (not in parsing) More...
 
class  ConversionError
 Thrown when conversion call back fails, such as when an int fails to coerce to a string. More...
 
class  Error
 All errors derive from this one. More...
 
class  ExcludesError
 Thrown when an excludes option is present. More...
 
class  ExtrasError
 Thrown when too many positionals or options are found. More...
 
class  FileError
 Thrown when parsing an INI file and it is missing. More...
 
class  FileOnDefaultPath
 
class  Formatter
 
class  FormatterBase
 
class  FormatterLambda
 This is a specialty override for lambda functions. More...
 
class  HorribleError
 
class  IncorrectConstruction
 Thrown when an option is set to conflicting values (non-vector and multi args, for example) More...
 
class  InvalidError
 Thrown when validation fails before parsing. More...
 
struct  is_bool
 Check to see if something is bool (fail check by default) More...
 
struct  is_bool< bool >
 Check to see if something is bool (true if actually a bool) More...
 
struct  is_copyable_ptr
 Check to see if something is copyable pointer. More...
 
struct  is_shared_ptr
 Check to see if something is a shared pointer. More...
 
struct  is_shared_ptr< const std::shared_ptr< T > >
 Check to see if something is a shared pointer (True if really a shared pointer) More...
 
struct  is_shared_ptr< std::shared_ptr< T > >
 Check to see if something is a shared pointer (True if really a shared pointer) More...
 
class  IsMember
 Verify items are in a set. More...
 
struct  IsMemberType
 This can be specialized to override the type deduction for IsMember. More...
 
struct  IsMemberType< const char * >
 The main custom type needed here is const char * should be a string. More...
 
struct  make_void
 A copy of std::void_t from C++17 (helper for C++11 and C++14) More...
 
class  Option
 
class  Option_group
 Extension of App to better manage groups of options. More...
 
class  OptionAlreadyAdded
 Thrown when an option already exists. More...
 
class  OptionBase
 
class  OptionDefaults
 
class  OptionNotFound
 Thrown when counting a nonexistent option. More...
 
class  ParseError
 Anything that can error in Parse. More...
 
class  Range
 Produce a range (factory). Min and max are inclusive. More...
 
class  RequiredError
 Thrown when a required option is missing. More...
 
class  RequiresError
 Thrown when a requires option is missing. More...
 
class  RuntimeError
 Does not output a diagnostic in CLI11_PARSE, but allows main() to return with a specific error code. More...
 
class  Success
 This is a successful completion on parsing, supposed to exit. More...
 
class  Timer
 This is a simple timer with pretty printing. Creating the timer starts counting. More...
 
class  Transformer
 Translate named items to other or a value set. More...
 
class  TypeValidator
 Validate the input as a particular type. More...
 
class  ValidationError
 Thrown when validation of results fails. More...
 
class  Validator
 Some validators that are provided. More...
 

Typedefs

using App_p = std::shared_ptr< App >
 
using ConfigTOML = ConfigBase
 the default Config is the TOML file format More...
 
template<typename T >
using TransformPairs = std::vector< std::pair< std::string, T >>
 definition of the default transformation object More...
 
using results_t = std::vector< std::string >
 
using callback_t = std::function< bool(const results_t &)>
 callback function definition More...
 
using Option_p = std::unique_ptr< Option >
 
using Validator_p = std::shared_ptr< Validator >
 
template<bool B, class T = void>
using enable_if_t = typename std::enable_if< B, T >::type
 
template<typename... Ts>
using void_t = typename make_void< Ts... >::type
 A copy of std::void_t from C++17 - same reasoning as enable_if_t, it does not hurt to redefine. More...
 
template<bool B, class T , class F >
using conditional_t = typename std::conditional< B, T, F >::type
 A copy of std::conditional_t from C++14 - same reasoning as enable_if_t, it does not hurt to redefine. More...
 

Enumerations

enum  ExtrasMode : std::uint8_t {
  ExtrasMode::Error = 0, ExtrasMode::ErrorImmediately, ExtrasMode::Ignore, ExtrasMode::AssumeSingleArgument,
  ExtrasMode::AssumeMultipleArguments, ExtrasMode::Capture
}
 enumeration of modes of how to deal with command line extras More...
 
enum  ConfigExtrasMode : std::uint8_t { ConfigExtrasMode::Error = 0, ConfigExtrasMode::Ignore, ConfigExtrasMode::IgnoreAll, ConfigExtrasMode::Capture }
 enumeration of modes of how to deal with extras in config files More...
 
enum  config_extras_mode : std::uint8_t { config_extras_mode::error = 0, config_extras_mode::ignore, config_extras_mode::ignore_all, config_extras_mode::capture }
 enumeration of modes of how to deal with extras in config files More...
 
enum  PrefixCommandMode : std::uint8_t { PrefixCommandMode::Off = 0, PrefixCommandMode::SeparatorOnly = 1, PrefixCommandMode::On = 2 }
 enumeration of prefix command modes, separator requires that the first extra argument be a "--", other unrecognized arguments will cause an error. on allows the first extra to trigger prefix mode regardless of other recognized options More...
 
enum  ExitCodes : int {
  ExitCodes::Success = 0, ExitCodes::IncorrectConstruction = 100, ExitCodes::BadNameString, ExitCodes::OptionAlreadyAdded,
  ExitCodes::FileError, ExitCodes::ConversionError, ExitCodes::ValidationError, ExitCodes::RequiredError,
  ExitCodes::RequiresError, ExitCodes::ExcludesError, ExitCodes::ExtrasError, ExitCodes::ConfigError,
  ExitCodes::InvalidError, ExitCodes::HorribleError, ExitCodes::OptionNotFound, ExitCodes::ArgumentMismatch,
  ExitCodes::BaseClass = 127
}
 
enum  AppFormatMode : std::uint8_t { AppFormatMode::Normal, AppFormatMode::All, AppFormatMode::Sub }
 
enum  MultiOptionPolicy : char {
  MultiOptionPolicy::Throw, MultiOptionPolicy::TakeLast, MultiOptionPolicy::TakeFirst, MultiOptionPolicy::Join,
  MultiOptionPolicy::TakeAll, MultiOptionPolicy::Sum, MultiOptionPolicy::Reverse
}
 Enumeration of the multiOption Policy selection. More...
 
enum  CallbackPriority : std::uint8_t {
  CallbackPriority::FirstPreHelp = 0, CallbackPriority::First = 1, CallbackPriority::PreRequirementsCheckPreHelp = 2, CallbackPriority::PreRequirementsCheck = 3,
  CallbackPriority::NormalPreHelp = 4, CallbackPriority::Normal = 5, CallbackPriority::LastPreHelp = 6, CallbackPriority::Last = 7
}
 enumeration for the callback priority More...
 

Functions

CLI11_INLINE void TriggerOn (App *trigger_app, App *app_to_enable)
 Helper function to enable one option group/subcommand when another is used. More...
 
CLI11_INLINE void TriggerOn (App *trigger_app, std::vector< App * > apps_to_enable)
 Helper function to enable one option group/subcommand when another is used. More...
 
CLI11_INLINE void TriggerOff (App *trigger_app, App *app_to_enable)
 Helper function to disable one option group/subcommand when another is used. More...
 
CLI11_INLINE void TriggerOff (App *trigger_app, std::vector< App * > apps_to_enable)
 Helper function to disable one option group/subcommand when another is used. More...
 
CLI11_INLINE void deprecate_option (Option *opt, const std::string &replacement="")
 Helper function to mark an option as deprecated. More...
 
void deprecate_option (App *app, const std::string &option_name, const std::string &replacement="")
 Helper function to mark an option as deprecated. More...
 
void deprecate_option (App &app, const std::string &option_name, const std::string &replacement="")
 Helper function to mark an option as deprecated. More...
 
CLI11_INLINE void retire_option (App *app, Option *opt)
 Helper function to mark an option as retired. More...
 
CLI11_INLINE void retire_option (App &app, Option *opt)
 Helper function to mark an option as retired. More...
 
CLI11_INLINE void retire_option (App *app, const std::string &option_name)
 Helper function to mark an option as retired. More...
 
CLI11_INLINE void retire_option (App &app, const std::string &option_name)
 Helper function to mark an option as retired. More...
 
CLI11_INLINE std::string narrow (const std::wstring &str)
 Convert a wide string to a narrow string. More...
 
CLI11_INLINE std::string narrow (const wchar_t *str)
 
CLI11_INLINE std::string narrow (const wchar_t *str, std::size_t size)
 
CLI11_INLINE std::wstring widen (const std::string &str)
 Convert a narrow string to a wide string. More...
 
CLI11_INLINE std::wstring widen (const char *str)
 
CLI11_INLINE std::wstring widen (const char *str, std::size_t size)
 
std::string ignore_case (std::string item)
 Helper function to allow ignore_case to be passed to IsMember or Transform. More...
 
std::string ignore_underscore (std::string item)
 Helper function to allow ignore_underscore to be passed to IsMember or Transform. More...
 
std::string ignore_space (std::string item)
 Helper function to allow checks to ignore spaces to be passed to IsMember or Transform. More...
 
AsNumberWithUnit::Options operator| (const AsNumberWithUnit::Options &a, const AsNumberWithUnit::Options &b)
 

Variables

const TypeValidator< double > Number ("NUMBER")
 Check for a number. More...
 
CLI11_MODULE_INLINE const detail::IPV4Validator ValidIPV4
 Check for an IP4 address. More...
 
using CustomValidator = Validator
 Alias for Validator for custom Validator for clarity. More...
 
CLI11_MODULE_INLINE const detail::ExistingFileValidator ExistingFile
 Check for existing file (returns error message if check fails) More...
 
CLI11_MODULE_INLINE const detail::ExistingDirectoryValidator ExistingDirectory
 Check for an existing directory (returns error message if check fails) More...
 
CLI11_MODULE_INLINE const detail::ExistingPathValidator ExistingPath
 Check for an existing path. More...
 
CLI11_MODULE_INLINE const detail::NonexistentPathValidator NonexistentPath
 Check for an non-existing path. More...
 
CLI11_MODULE_INLINE const detail::EscapedStringTransformer EscapedString
 convert escaped characters into their associated values More...
 
CLI11_MODULE_INLINE const Range NonNegativeNumber ((std::numeric_limits< double >::max)(),"NONNEGATIVE")
 Check for a non negative number. More...
 
CLI11_MODULE_INLINE const Range PositiveNumber ((std::numeric_limits< double >::min)(),(std::numeric_limits< double >::max)(),"POSITIVE")
 Check for a positive valued number (val>0.0), <double>::min here is the smallest positive number. More...
 

Typedef Documentation

using CLI::App_p = typedef std::shared_ptr<App>
using CLI::callback_t = typedef std::function<bool(const results_t &)>

callback function definition

template<bool B, class T , class F >
using CLI::conditional_t = typedef typename std::conditional<B, T, F>::type

A copy of std::conditional_t from C++14 - same reasoning as enable_if_t, it does not hurt to redefine.

using CLI::ConfigTOML = typedef ConfigBase

the default Config is the TOML file format

Alias for Validator for custom Validator for clarity.

template<bool B, class T = void>
using CLI::enable_if_t = typedef typename std::enable_if<B, T>::type

A copy of enable_if_t from C++14, compatible with C++11.

We could check to see if C++14 is being used, but it does not hurt to redefine this (even Google does this: https://github.com/google/skia/blob/main/include/private/SkTLogic.h) It is not in the std namespace anyway, so no harm done.

using CLI::Option_p = typedef std::unique_ptr<Option>
using CLI::results_t = typedef std::vector<std::string>
template<typename T >
using CLI::TransformPairs = typedef std::vector<std::pair<std::string, T>>

definition of the default transformation object

using CLI::Validator_p = typedef std::shared_ptr<Validator>
template<typename... Ts>
using CLI::void_t = typedef typename make_void<Ts...>::type

A copy of std::void_t from C++17 - same reasoning as enable_if_t, it does not hurt to redefine.

Enumeration Type Documentation

enum CLI::AppFormatMode : std::uint8_t
strong

This enum signifies the type of help requested

This is passed in by App; all user classes must accept this as the second argument.

Enumerator
Normal 

The normal, detailed help.

All 

A fully expanded help.

Sub 

Used when printed as part of expanded subcommand.

enum CLI::CallbackPriority : std::uint8_t
strong

enumeration for the callback priority

Enumerator
FirstPreHelp 
First 
PreRequirementsCheckPreHelp 
PreRequirementsCheck 
NormalPreHelp 
Normal 
LastPreHelp 
Last 
enum CLI::config_extras_mode : std::uint8_t
strong

enumeration of modes of how to deal with extras in config files

Enumerator
error 
ignore 
ignore_all 
capture 
enum CLI::ConfigExtrasMode : std::uint8_t
strong

enumeration of modes of how to deal with extras in config files

Enumerator
Error 
Ignore 
IgnoreAll 
Capture 
enum CLI::ExitCodes : int
strong

These codes are part of every error in CLI. They can be obtained from e using e.exit_code or as a quick shortcut, int values from e.get_error_code().

Enumerator
Success 
IncorrectConstruction 
BadNameString 
OptionAlreadyAdded 
FileError 
ConversionError 
ValidationError 
RequiredError 
RequiresError 
ExcludesError 
ExtrasError 
ConfigError 
InvalidError 
HorribleError 
OptionNotFound 
ArgumentMismatch 
BaseClass 
enum CLI::ExtrasMode : std::uint8_t
strong

enumeration of modes of how to deal with command line extras

Enumerator
Error 
ErrorImmediately 
Ignore 
AssumeSingleArgument 
AssumeMultipleArguments 
Capture 
enum CLI::MultiOptionPolicy : char
strong

Enumeration of the multiOption Policy selection.

Enumerator
Throw 

Throw an error if any extra arguments were given.

TakeLast 

take only the last Expected number of arguments

TakeFirst 

take only the first Expected number of arguments

Join 

merge all the arguments together into a single string via the delimiter character default('
')

TakeAll 

just get all the passed argument regardless

Sum 

sum all the arguments together if numerical or concatenate directly without delimiter

Reverse 

take only the last Expected number of arguments in reverse order

enum CLI::PrefixCommandMode : std::uint8_t
strong

enumeration of prefix command modes, separator requires that the first extra argument be a "--", other unrecognized arguments will cause an error. on allows the first extra to trigger prefix mode regardless of other recognized options

Enumerator
Off 
SeparatorOnly 
On 

Function Documentation

CLI11_INLINE void CLI::deprecate_option ( Option opt,
const std::string &  replacement = "" 
)

Helper function to mark an option as deprecated.

void CLI::deprecate_option ( App app,
const std::string &  option_name,
const std::string &  replacement = "" 
)
inline

Helper function to mark an option as deprecated.

void CLI::deprecate_option ( App app,
const std::string &  option_name,
const std::string &  replacement = "" 
)
inline

Helper function to mark an option as deprecated.

std::string CLI::ignore_case ( std::string  item)
inline

Helper function to allow ignore_case to be passed to IsMember or Transform.

std::string CLI::ignore_space ( std::string  item)
inline

Helper function to allow checks to ignore spaces to be passed to IsMember or Transform.

std::string CLI::ignore_underscore ( std::string  item)
inline

Helper function to allow ignore_underscore to be passed to IsMember or Transform.

CLI11_INLINE std::string CLI::narrow ( const std::wstring &  str)

Convert a wide string to a narrow string.

CLI11_INLINE std::string CLI::narrow ( const wchar_t *  str)
CLI11_INLINE std::string CLI::narrow ( const wchar_t *  str,
std::size_t  size 
)
CLI11_MODULE_INLINE const Range CLI::NonNegativeNumber ( (std::numeric_limits< double >::max)()  ,
"NONNEGATIVE"   
)

Check for a non negative number.

AsNumberWithUnit::Options CLI::operator| ( const AsNumberWithUnit::Options a,
const AsNumberWithUnit::Options b 
)
inline
CLI11_MODULE_INLINE const Range CLI::PositiveNumber ( (std::numeric_limits< double >::min)()  ,
(std::numeric_limits< double >::max)()  ,
"POSITIVE"   
)

Check for a positive valued number (val>0.0), <double>::min here is the smallest positive number.

CLI11_INLINE void CLI::retire_option ( App app,
Option opt 
)

Helper function to mark an option as retired.

CLI11_INLINE void CLI::retire_option ( App app,
Option opt 
)

Helper function to mark an option as retired.

CLI11_INLINE void CLI::retire_option ( App app,
const std::string &  option_name 
)

Helper function to mark an option as retired.

CLI11_INLINE void CLI::retire_option ( App app,
const std::string &  option_name 
)

Helper function to mark an option as retired.

CLI11_INLINE void CLI::TriggerOff ( App trigger_app,
App app_to_enable 
)

Helper function to disable one option group/subcommand when another is used.

CLI11_INLINE void CLI::TriggerOff ( App trigger_app,
std::vector< App * >  apps_to_enable 
)

Helper function to disable one option group/subcommand when another is used.

CLI11_INLINE void CLI::TriggerOn ( App trigger_app,
App app_to_enable 
)

Helper function to enable one option group/subcommand when another is used.

CLI11_INLINE void CLI::TriggerOn ( App trigger_app,
std::vector< App * >  apps_to_enable 
)

Helper function to enable one option group/subcommand when another is used.

CLI11_INLINE std::wstring CLI::widen ( const std::string &  str)

Convert a narrow string to a wide string.

CLI11_INLINE std::wstring CLI::widen ( const char *  str)
CLI11_INLINE std::wstring CLI::widen ( const char *  str,
std::size_t  size 
)

Variable Documentation

convert escaped characters into their associated values

Check for an existing directory (returns error message if check fails)

Check for existing file (returns error message if check fails)

Check for an existing path.

Check for an non-existing path.

const TypeValidator<double> CLI::Number("NUMBER")

Check for a number.

Check for an IP4 address.