koutil
Loading...
Searching...
No Matches
koutil::args::result_base_t Class Reference

Represents the result of command-line parsing. More...

#include <result.h>

Public Member Functions

 result_base_t ()=default
 
bool has_error () const
 Checks if any errors occurred.
 
bool need_exit () const
 Checks if the parser requested program exit.
 
const auto & errors () const
 Returns the list of error messages.
 
void add_error (std::string error)
 Adds an error message.
 
void exit ()
 Marks the result as requiring exit.
 

Private Attributes

bool m_exit = false
 
std::vector< std::string > m_errors
 

Detailed Description

Represents the result of command-line parsing.

The order in which options, arguments, and commands are added is significant:

  • The order of arguments defines the expected order on the command line.
  • The order of options, arguments, and commands determines how they appear in the help text.

Constructor & Destructor Documentation

◆ result_base_t()

koutil::args::result_base_t::result_base_t ( )
default

Member Function Documentation

◆ add_error()

void koutil::args::result_base_t::add_error ( std::string error)
inline

Adds an error message.

Parameters
errorError text.

◆ errors()

const auto & koutil::args::result_base_t::errors ( ) const
inlinenodiscard

Returns the list of error messages.

Returns
Errors.

◆ exit()

void koutil::args::result_base_t::exit ( )
inline

Marks the result as requiring exit.

Note
Useful for commands like –help to stop parsing.

◆ has_error()

bool koutil::args::result_base_t::has_error ( ) const
inlinenodiscard

Checks if any errors occurred.

Returns
True if there are errors.

◆ need_exit()

bool koutil::args::result_base_t::need_exit ( ) const
inlinenodiscard

Checks if the parser requested program exit.

Returns
True if exit is required.
Note
Can be used for options like –help to skip further validation and avoid errors when required arguments are missing.

Member Data Documentation

◆ m_errors

std::vector<std::string> koutil::args::result_base_t::m_errors
private

◆ m_exit

bool koutil::args::result_base_t::m_exit = false
private

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