5 #include <argparse/argparse.hpp>
7 using argparse::ArgumentParser;
19 using ArgumentParser::ArgumentParser;
24 const std::string
name()
const{
25 return this->m_program_name;
30 const std::list<std::reference_wrapper<ArgumentParser>>&
subparsers()
const{
31 return this->m_subparsers;
41 for (
const std::reference_wrapper<ArgumentParser>& subparser : this->m_subparsers) {
42 if (this->is_subcommand_used(subparser.get())) {
51 std::vector<std::string> names;
52 for (
const auto& [
name, _] : this->m_argument_map) {
53 if (
name.size() >= 2 &&
name[0] ==
'-' &&
name[1] ==
'-')
54 names.push_back(
name);
61 auto it = this->m_argument_map.find(
name);
62 if (it == this->m_argument_map.end())
return false;
64 return it->second->get_usage_full().find(
' ') != std::string::npos;
Extended ArgumentParser with MaCh3-specific functionality.
const std::string name() const
Get the name of this parser/subcommand.
virtual ~MaCh3ArgumentParser()=default
std::vector< std::string > get_long_option_names() const
Return all long option names (–xxx) registered with this parser.
const std::list< std::reference_wrapper< ArgumentParser > > & subparsers() const
Get the list of registered subparsers.
bool option_takes_value(const std::string &name) const
Return true if the named option expects a value (not a flag)
const MaCh3ArgumentParser & get_subcommand_used() const
Get the subcommand that was used in parsing.
Main namespace for MaCh3 software.