mirror of
https://github.com/CLIUtils/CLI11.git
synced 2025-05-01 13:13:53 +00:00
A few warning fixes
This commit is contained in:
parent
1286a1226e
commit
c6fd8f4d83
@ -1511,13 +1511,13 @@ inline std::string simple(const App *app, const Error &e) {
|
|||||||
if(app->get_help_ptr() != nullptr)
|
if(app->get_help_ptr() != nullptr)
|
||||||
header += "Run with " + app->get_help_ptr()->single_name() + " for more information.\n";
|
header += "Run with " + app->get_help_ptr()->single_name() + " for more information.\n";
|
||||||
return header;
|
return header;
|
||||||
};
|
}
|
||||||
|
|
||||||
inline std::string help(const App *app, const Error &e) {
|
inline std::string help(const App *app, const Error &e) {
|
||||||
std::string header = std::string("ERROR: ") + e.get_name() + ": " + e.what() + "\n";
|
std::string header = std::string("ERROR: ") + e.get_name() + ": " + e.what() + "\n";
|
||||||
header += app->help();
|
header += app->help();
|
||||||
return header;
|
return header;
|
||||||
};
|
}
|
||||||
|
|
||||||
} // namespace FailureMessage
|
} // namespace FailureMessage
|
||||||
|
|
||||||
|
@ -6,23 +6,25 @@
|
|||||||
#include <exception>
|
#include <exception>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
|
namespace CLI {
|
||||||
|
|
||||||
// Use one of these on all error classes
|
// Use one of these on all error classes
|
||||||
#define CLI11_ERROR_DEF(parent, name) \
|
#define CLI11_ERROR_DEF(parent, name) \
|
||||||
protected: \
|
protected: \
|
||||||
name(std::string name, std::string msg, int exit_code) : parent(name, msg, exit_code) {} \
|
name(std::string name, std::string msg, int exit_code) : parent(std::move(name), std::move(msg), exit_code) {} \
|
||||||
name(std::string name, std::string msg, ExitCodes exit_code) : parent(name, msg, exit_code) {} \
|
name(std::string name, std::string msg, ExitCodes exit_code) \
|
||||||
|
: parent(std::move(name), std::move(msg), exit_code) {} \
|
||||||
\
|
\
|
||||||
public: \
|
public: \
|
||||||
name(std::string msg, ExitCodes exit_code) : parent(#name, msg, exit_code) {} \
|
name(std::string msg, ExitCodes exit_code) : parent(#name, std::move(msg), exit_code) {} \
|
||||||
name(std::string msg, int exit_code) : parent(#name, msg, exit_code) {}
|
name(std::string msg, int exit_code) : parent(#name, std::move(msg), exit_code) {}
|
||||||
|
|
||||||
// This is added after the one above if a class is used directly and builds its own message
|
// This is added after the one above if a class is used directly and builds its own message
|
||||||
#define CLI11_ERROR_SIMPLE(name) \
|
#define CLI11_ERROR_SIMPLE(name) \
|
||||||
name(std::string msg) : name(#name, msg, ExitCodes::name) {}
|
name(std::string msg) : name(#name, msg, ExitCodes::name) {}
|
||||||
|
|
||||||
namespace CLI {
|
|
||||||
|
|
||||||
/// These codes are part of every error in CLI. They can be obtained from e using e.exit_code or as a quick shortcut,
|
/// 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().
|
/// int values from e.get_error_code().
|
||||||
enum class ExitCodes {
|
enum class ExitCodes {
|
||||||
@ -63,7 +65,7 @@ class Error : public std::runtime_error {
|
|||||||
std::string get_name() const { return name; }
|
std::string get_name() const { return name; }
|
||||||
|
|
||||||
Error(std::string name, std::string msg, int exit_code = static_cast<int>(ExitCodes::BaseClass))
|
Error(std::string name, std::string msg, int exit_code = static_cast<int>(ExitCodes::BaseClass))
|
||||||
: runtime_error(msg), exit_code(exit_code), name(name) {}
|
: runtime_error(msg), exit_code(exit_code), name(std::move(name)) {}
|
||||||
|
|
||||||
Error(std::string name, std::string msg, ExitCodes exit_code) : Error(name, msg, static_cast<int>(exit_code)) {}
|
Error(std::string name, std::string msg, ExitCodes exit_code) : Error(name, msg, static_cast<int>(exit_code)) {}
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user