mirror of
https://github.com/CLIUtils/CLI11.git
synced 2025-05-03 14:03:52 +00:00
Adding more to documentation
This commit is contained in:
parent
a461680520
commit
9d6830e8d2
@ -1632,6 +1632,7 @@ class App {
|
|||||||
|
|
||||||
namespace FailureMessage {
|
namespace FailureMessage {
|
||||||
|
|
||||||
|
/// Printout a clean, simple message on error (the default in CLI11 1.5+)
|
||||||
inline std::string simple(const App *app, const Error &e) {
|
inline std::string simple(const App *app, const Error &e) {
|
||||||
std::string header = std::string(e.what()) + "\n";
|
std::string header = std::string(e.what()) + "\n";
|
||||||
if(app->get_help_ptr() != nullptr)
|
if(app->get_help_ptr() != nullptr)
|
||||||
@ -1639,6 +1640,7 @@ inline std::string simple(const App *app, const Error &e) {
|
|||||||
return header;
|
return header;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Printout the full help string on error (if this fn is set, the old default for CLI11)
|
||||||
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();
|
||||||
|
@ -97,6 +97,8 @@ class FormatterLambda final : public FormatterBase {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// This is the default Formatter for CLI11. It pretty prints help output, and is broken into quite a few
|
||||||
|
/// overridable methods, to be highly customizable with minimal effort.
|
||||||
class Formatter : public FormatterBase {
|
class Formatter : public FormatterBase {
|
||||||
public:
|
public:
|
||||||
Formatter() = default;
|
Formatter() = default;
|
||||||
|
@ -30,6 +30,8 @@ using Option_p = std::unique_ptr<Option>;
|
|||||||
|
|
||||||
enum class MultiOptionPolicy { Throw, TakeLast, TakeFirst, Join };
|
enum class MultiOptionPolicy { Throw, TakeLast, TakeFirst, Join };
|
||||||
|
|
||||||
|
/// This is the CRTP base class for Option and OptionDefaults. It was designed this way
|
||||||
|
/// to share parts of the class; an OptionDefaults can copy to an Option.
|
||||||
template <typename CRTP> class OptionBase {
|
template <typename CRTP> class OptionBase {
|
||||||
friend App;
|
friend App;
|
||||||
|
|
||||||
@ -123,6 +125,8 @@ template <typename CRTP> class OptionBase {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// This is a version of OptionBase that only supports setting values,
|
||||||
|
/// for defaults. It is stored as the default option in an App.
|
||||||
class OptionDefaults : public OptionBase<OptionDefaults> {
|
class OptionDefaults : public OptionBase<OptionDefaults> {
|
||||||
public:
|
public:
|
||||||
OptionDefaults() = default;
|
OptionDefaults() = default;
|
||||||
@ -287,7 +291,7 @@ class Option : public OptionBase<Option> {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Adds a validator
|
/// Adds a validator. Takes a const string& and returns an error message (empty if conversion/check is okay).
|
||||||
Option *check(std::function<std::string(const std::string &)> validator) {
|
Option *check(std::function<std::string(const std::string &)> validator) {
|
||||||
validators_.emplace_back(validator);
|
validators_.emplace_back(validator);
|
||||||
return this;
|
return this;
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
namespace CLI {
|
namespace CLI {
|
||||||
|
|
||||||
|
/// This is a simple timer with pretty printing. Creating the timer starts counting.
|
||||||
class Timer {
|
class Timer {
|
||||||
protected:
|
protected:
|
||||||
/// This is a typedef to make clocks easier to use
|
/// This is a typedef to make clocks easier to use
|
||||||
|
@ -12,18 +12,24 @@ namespace CLI {
|
|||||||
|
|
||||||
// Type tools
|
// Type tools
|
||||||
|
|
||||||
// We could check to see if C++14 is being used, but it does not hurt to redefine this
|
/// A copy of enable_if_t from C++14, compatible with C++11.
|
||||||
// (even Google does this: https://github.com/google/skia/blob/master/include/private/SkTLogic.h)
|
///
|
||||||
// It is not in the std namespace anyway, so no harm done.
|
/// 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/master/include/private/SkTLogic.h)
|
||||||
|
/// It is not in the std namespace anyway, so no harm done.
|
||||||
|
|
||||||
template <bool B, class T = void> using enable_if_t = typename std::enable_if<B, T>::type;
|
template <bool B, class T = void> using enable_if_t = typename std::enable_if<B, T>::type;
|
||||||
|
|
||||||
|
/// Check to see if something is a vector (fail check by default)
|
||||||
template <typename T> struct is_vector { static const bool value = false; };
|
template <typename T> struct is_vector { static const bool value = false; };
|
||||||
|
|
||||||
|
/// Check to see if something is a vector (true if actually a vector)
|
||||||
template <class T, class A> struct is_vector<std::vector<T, A>> { static bool const value = true; };
|
template <class T, class A> struct is_vector<std::vector<T, A>> { static bool const value = true; };
|
||||||
|
|
||||||
|
/// Check to see if something is bool (fail check by default)
|
||||||
template <typename T> struct is_bool { static const bool value = false; };
|
template <typename T> struct is_bool { static const bool value = false; };
|
||||||
|
|
||||||
|
/// Check to see if something is bool (true if actually a bool)
|
||||||
template <> struct is_bool<bool> { static bool const value = true; };
|
template <> struct is_bool<bool> { static bool const value = true; };
|
||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user