MaCh3  2.6.1
Reference Guide
m3argparse.hpp
Go to the documentation of this file.
1 
4 #pragma once
5 #include <argparse/argparse.hpp>
6 
7 using argparse::ArgumentParser;
8 
9 namespace M3 {
10 
17  class MaCh3ArgumentParser: public ArgumentParser{
18  public:
19  using ArgumentParser::ArgumentParser;
20  virtual ~MaCh3ArgumentParser() = default;
21 
24  const std::string name() const{
25  return this->m_program_name;
26  }
27 
30  const std::list<std::reference_wrapper<ArgumentParser>>& subparsers() const{
31  return this->m_subparsers;
32  }
33 
41  for (const std::reference_wrapper<ArgumentParser>& subparser : this->m_subparsers) {
42  if (this->is_subcommand_used(subparser.get())) {
43  return static_cast<MaCh3ArgumentParser*>(&(subparser.get()))->get_subcommand_used();
44  }
45  }
46  return (*this);
47  }
48  };
49 }
Extended ArgumentParser with MaCh3-specific functionality.
Definition: m3argparse.hpp:17
const std::string name() const
Get the name of this parser/subcommand.
Definition: m3argparse.hpp:24
virtual ~MaCh3ArgumentParser()=default
const std::list< std::reference_wrapper< ArgumentParser > > & subparsers() const
Get the list of registered subparsers.
Definition: m3argparse.hpp:30
const MaCh3ArgumentParser & get_subcommand_used() const
Get the subcommand that was used in parsing.
Definition: m3argparse.hpp:40
Main namespace for MaCh3 software.