|
kaycxx-cli
C++ CLI library
|
Options and positional parameters are typed. Their value types must be copy-constructible and support at least one of the conversion methods listed below.
Conversion is selected in this order:
std::from_chars for supported numeric and similar standard types.from_string function for custom types.std::string_view, including std::string.std::from_chars must consume the complete argument text. Trailing invalid text is rejected.
Define from_string in the same namespace as the custom type. Argument-dependent lookup finds it when the command instantiates an option or parameter for that type.
The type can then be used directly.
The required customization signature is:
The std::type_identity<T> argument distinguishes conversions by result type without requiring a dummy value. A thrown parse_error is preserved. Other standard exceptions thrown by custom conversions or std::string_view constructors are converted to parse_error, and their what() message is appended to the invalid-value message.
Use a flag instead of option<bool> for a simple enabled/disabled switch. Options are intended for values explicitly supplied by the user.