Commit 9d6830e8d2da920699a861d880137b91369f6563
1 parent
a4616805
Adding more to documentation
Showing
5 changed files
with
19 additions
and
4 deletions
include/CLI/App.hpp
| @@ -1632,6 +1632,7 @@ class App { | @@ -1632,6 +1632,7 @@ class App { | ||
| 1632 | 1632 | ||
| 1633 | namespace FailureMessage { | 1633 | namespace FailureMessage { |
| 1634 | 1634 | ||
| 1635 | +/// Printout a clean, simple message on error (the default in CLI11 1.5+) | ||
| 1635 | inline std::string simple(const App *app, const Error &e) { | 1636 | inline std::string simple(const App *app, const Error &e) { |
| 1636 | std::string header = std::string(e.what()) + "\n"; | 1637 | std::string header = std::string(e.what()) + "\n"; |
| 1637 | if(app->get_help_ptr() != nullptr) | 1638 | if(app->get_help_ptr() != nullptr) |
| @@ -1639,6 +1640,7 @@ inline std::string simple(const App *app, const Error &e) { | @@ -1639,6 +1640,7 @@ inline std::string simple(const App *app, const Error &e) { | ||
| 1639 | return header; | 1640 | return header; |
| 1640 | } | 1641 | } |
| 1641 | 1642 | ||
| 1643 | +/// Printout the full help string on error (if this fn is set, the old default for CLI11) | ||
| 1642 | inline std::string help(const App *app, const Error &e) { | 1644 | inline std::string help(const App *app, const Error &e) { |
| 1643 | std::string header = std::string("ERROR: ") + e.get_name() + ": " + e.what() + "\n"; | 1645 | std::string header = std::string("ERROR: ") + e.get_name() + ": " + e.what() + "\n"; |
| 1644 | header += app->help(); | 1646 | header += app->help(); |
include/CLI/FormatterFwd.hpp
| @@ -97,6 +97,8 @@ class FormatterLambda final : public FormatterBase { | @@ -97,6 +97,8 @@ class FormatterLambda final : public FormatterBase { | ||
| 97 | } | 97 | } |
| 98 | }; | 98 | }; |
| 99 | 99 | ||
| 100 | +/// This is the default Formatter for CLI11. It pretty prints help output, and is broken into quite a few | ||
| 101 | +/// overridable methods, to be highly customizable with minimal effort. | ||
| 100 | class Formatter : public FormatterBase { | 102 | class Formatter : public FormatterBase { |
| 101 | public: | 103 | public: |
| 102 | Formatter() = default; | 104 | Formatter() = default; |
include/CLI/Option.hpp
| @@ -30,6 +30,8 @@ using Option_p = std::unique_ptr<Option>; | @@ -30,6 +30,8 @@ using Option_p = std::unique_ptr<Option>; | ||
| 30 | 30 | ||
| 31 | enum class MultiOptionPolicy { Throw, TakeLast, TakeFirst, Join }; | 31 | enum class MultiOptionPolicy { Throw, TakeLast, TakeFirst, Join }; |
| 32 | 32 | ||
| 33 | +/// This is the CRTP base class for Option and OptionDefaults. It was designed this way | ||
| 34 | +/// to share parts of the class; an OptionDefaults can copy to an Option. | ||
| 33 | template <typename CRTP> class OptionBase { | 35 | template <typename CRTP> class OptionBase { |
| 34 | friend App; | 36 | friend App; |
| 35 | 37 | ||
| @@ -123,6 +125,8 @@ template <typename CRTP> class OptionBase { | @@ -123,6 +125,8 @@ template <typename CRTP> class OptionBase { | ||
| 123 | } | 125 | } |
| 124 | }; | 126 | }; |
| 125 | 127 | ||
| 128 | +/// This is a version of OptionBase that only supports setting values, | ||
| 129 | +/// for defaults. It is stored as the default option in an App. | ||
| 126 | class OptionDefaults : public OptionBase<OptionDefaults> { | 130 | class OptionDefaults : public OptionBase<OptionDefaults> { |
| 127 | public: | 131 | public: |
| 128 | OptionDefaults() = default; | 132 | OptionDefaults() = default; |
| @@ -287,7 +291,7 @@ class Option : public OptionBase<Option> { | @@ -287,7 +291,7 @@ class Option : public OptionBase<Option> { | ||
| 287 | return this; | 291 | return this; |
| 288 | } | 292 | } |
| 289 | 293 | ||
| 290 | - /// Adds a validator | 294 | + /// Adds a validator. Takes a const string& and returns an error message (empty if conversion/check is okay). |
| 291 | Option *check(std::function<std::string(const std::string &)> validator) { | 295 | Option *check(std::function<std::string(const std::string &)> validator) { |
| 292 | validators_.emplace_back(validator); | 296 | validators_.emplace_back(validator); |
| 293 | return this; | 297 | return this; |
include/CLI/Timer.hpp
| @@ -17,6 +17,7 @@ | @@ -17,6 +17,7 @@ | ||
| 17 | 17 | ||
| 18 | namespace CLI { | 18 | namespace CLI { |
| 19 | 19 | ||
| 20 | +/// This is a simple timer with pretty printing. Creating the timer starts counting. | ||
| 20 | class Timer { | 21 | class Timer { |
| 21 | protected: | 22 | protected: |
| 22 | /// This is a typedef to make clocks easier to use | 23 | /// This is a typedef to make clocks easier to use |
include/CLI/TypeTools.hpp
| @@ -12,18 +12,24 @@ namespace CLI { | @@ -12,18 +12,24 @@ namespace CLI { | ||
| 12 | 12 | ||
| 13 | // Type tools | 13 | // Type tools |
| 14 | 14 | ||
| 15 | -// We could check to see if C++14 is being used, but it does not hurt to redefine this | ||
| 16 | -// (even Google does this: https://github.com/google/skia/blob/master/include/private/SkTLogic.h) | ||
| 17 | -// It is not in the std namespace anyway, so no harm done. | 15 | +/// A copy of enable_if_t from C++14, compatible with C++11. |
| 16 | +/// | ||
| 17 | +/// We could check to see if C++14 is being used, but it does not hurt to redefine this | ||
| 18 | +/// (even Google does this: https://github.com/google/skia/blob/master/include/private/SkTLogic.h) | ||
| 19 | +/// It is not in the std namespace anyway, so no harm done. | ||
| 18 | 20 | ||
| 19 | template <bool B, class T = void> using enable_if_t = typename std::enable_if<B, T>::type; | 21 | template <bool B, class T = void> using enable_if_t = typename std::enable_if<B, T>::type; |
| 20 | 22 | ||
| 23 | +/// Check to see if something is a vector (fail check by default) | ||
| 21 | template <typename T> struct is_vector { static const bool value = false; }; | 24 | template <typename T> struct is_vector { static const bool value = false; }; |
| 22 | 25 | ||
| 26 | +/// Check to see if something is a vector (true if actually a vector) | ||
| 23 | template <class T, class A> struct is_vector<std::vector<T, A>> { static bool const value = true; }; | 27 | template <class T, class A> struct is_vector<std::vector<T, A>> { static bool const value = true; }; |
| 24 | 28 | ||
| 29 | +/// Check to see if something is bool (fail check by default) | ||
| 25 | template <typename T> struct is_bool { static const bool value = false; }; | 30 | template <typename T> struct is_bool { static const bool value = false; }; |
| 26 | 31 | ||
| 32 | +/// Check to see if something is bool (true if actually a bool) | ||
| 27 | template <> struct is_bool<bool> { static bool const value = true; }; | 33 | template <> struct is_bool<bool> { static bool const value = true; }; |
| 28 | 34 | ||
| 29 | namespace detail { | 35 | namespace detail { |