#pragma once // Distributed under the 3-Clause BSD License. See accompanying // file LICENSE or https://github.com/CLIUtils/CLI11 for details. #include #include #include #include #include #include #include #include #include #include #include // CLI Library includes #include "CLI/Error.hpp" #include "CLI/Ini.hpp" #include "CLI/Option.hpp" #include "CLI/Split.hpp" #include "CLI/StringTools.hpp" #include "CLI/TypeTools.hpp" namespace CLI { namespace detail { enum class Classifer { NONE, POSITIONAL_MARK, SHORT, LONG, SUBCOMMAND }; struct AppFriend; } // namespace detail class App; using App_p = std::unique_ptr; /// Creates a command line program, with very few defaults. /** To use, create a new `Program()` instance with `argc`, `argv`, and a help description. The templated * add_option methods make it easy to prepare options. Remember to call `.start` before starting your * program, so that the options can be evaluated and the help option doesn't accidentally run your program. */ class App { friend Option; friend detail::AppFriend; protected: // This library follows the Google style guide for member names ending in underscores /// @name Basics ///@{ /// Subcommand name or program name (from parser) std::string name_{"program"}; /// Description of the current program/subcommand std::string description_; /// If true, allow extra arguments (ie, don't throw an error). bool allow_extras_{false}; /// If true, return immediatly on an unrecognised option (implies allow_extras) bool prefix_command_{false}; /// This is a function that runs when complete. Great for subcommands. Can throw. std::function callback_; ///@} /// @name Options ///@{ /// The list of options, stored locally std::vector options_; /// A pointer to the help flag if there is one Option *help_ptr_{nullptr}; ///@} /// @name Parsing ///@{ using missing_t = std::vector>; /// Pair of classifier, string for missing options. (extra detail is removed on returning from parse) /// /// This is faster and cleaner than storing just a list of strings and reparsing. This may contain the -- separator. missing_t missing_; /// This is a list of pointers to options with the orignal parse order std::vector