1
0
mirror of https://github.com/CLIUtils/CLI11.git synced 2025-05-08 15:53:51 +00:00

A few more explicit constructors

This commit is contained in:
Henry Fredrick Schreiner 2018-04-13 14:15:09 +02:00
parent b23275358a
commit bd890e24a1

View File

@ -160,7 +160,7 @@ class CallForHelp : public ParseError {
/// Does not output a diagnostic in CLI11_PARSE, but allows to return from main() with a specific error code. /// Does not output a diagnostic in CLI11_PARSE, but allows to return from main() with a specific error code.
class RuntimeError : public ParseError { class RuntimeError : public ParseError {
CLI11_ERROR_DEF(ParseError, RuntimeError) CLI11_ERROR_DEF(ParseError, RuntimeError)
RuntimeError(int exit_code = 1) : RuntimeError("Runtime error", exit_code) {} explicit RuntimeError(int exit_code = 1) : RuntimeError("Runtime error", exit_code) {}
}; };
/// Thrown when parsing an INI file and it is missing /// Thrown when parsing an INI file and it is missing
@ -242,7 +242,7 @@ class ExcludesError : public ParseError {
/// Thrown when too many positionals or options are found /// Thrown when too many positionals or options are found
class ExtrasError : public ParseError { class ExtrasError : public ParseError {
CLI11_ERROR_DEF(ParseError, ExtrasError) CLI11_ERROR_DEF(ParseError, ExtrasError)
ExtrasError(std::vector<std::string> args) explicit ExtrasError(std::vector<std::string> args)
: ExtrasError((args.size() > 1 ? "The following arguments were not expected: " : ExtrasError((args.size() > 1 ? "The following arguments were not expected: "
: "The following argument was not expected: ") + : "The following argument was not expected: ") +
detail::rjoin(args, " "), detail::rjoin(args, " "),
@ -279,7 +279,7 @@ class HorribleError : public ParseError {
/// Thrown when counting a non-existent option /// Thrown when counting a non-existent option
class OptionNotFound : public Error { class OptionNotFound : public Error {
CLI11_ERROR_DEF(Error, OptionNotFound) CLI11_ERROR_DEF(Error, OptionNotFound)
OptionNotFound(std::string name) : OptionNotFound(name + " not found", ExitCodes::OptionNotFound) {} explicit OptionNotFound(std::string name) : OptionNotFound(name + " not found", ExitCodes::OptionNotFound) {}
}; };
/// @} /// @}