MaCh3  2.6.1
Reference Guide
Public Member Functions | List of all members
M3::MaCh3ArgumentParser Class Reference

Extended ArgumentParser with MaCh3-specific functionality. More...

#include <CLI/API/m3argparse.hpp>

Inheritance diagram for M3::MaCh3ArgumentParser:
[legend]
Collaboration diagram for M3::MaCh3ArgumentParser:
[legend]

Public Member Functions

virtual ~MaCh3ArgumentParser ()=default
 
const std::string name () const
 Get the name of this parser/subcommand. More...
 
const std::list< std::reference_wrapper< ArgumentParser > > & subparsers () const
 Get the list of registered subparsers. More...
 
const MaCh3ArgumentParserget_subcommand_used () const
 Get the subcommand that was used in parsing. More...
 

Detailed Description

Extended ArgumentParser with MaCh3-specific functionality.

This class extends the standard ArgumentParser to provide additional methods for accessing parser name, subparsers, and tracking which subcommand was used.

Definition at line 17 of file m3argparse.hpp.

Constructor & Destructor Documentation

◆ ~MaCh3ArgumentParser()

virtual M3::MaCh3ArgumentParser::~MaCh3ArgumentParser ( )
virtualdefault

Member Function Documentation

◆ get_subcommand_used()

const MaCh3ArgumentParser& M3::MaCh3ArgumentParser::get_subcommand_used ( ) const
inline

Get the subcommand that was used in parsing.

Recursively traverses the subparser hierarchy to find the deepest subcommand that was actually invoked.

Returns
Reference to the MaCh3ArgumentParser of the used subcommand

Definition at line 40 of file m3argparse.hpp.

40  {
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  }

◆ name()

const std::string M3::MaCh3ArgumentParser::name ( ) const
inline

Get the name of this parser/subcommand.

Returns
The program or subcommand name

Definition at line 24 of file m3argparse.hpp.

24  {
25  return this->m_program_name;
26  }

◆ subparsers()

const std::list<std::reference_wrapper<ArgumentParser> >& M3::MaCh3ArgumentParser::subparsers ( ) const
inline

Get the list of registered subparsers.

Returns
Reference to the list of subparsers

Definition at line 30 of file m3argparse.hpp.

30  {
31  return this->m_subparsers;
32  }

The documentation for this class was generated from the following file: