CPP-ARGON 4.0.1
Command-Line Argument Parser for C++20
Loading...
Searching...
No Matches
argon Namespace Reference

Namespaces

namespace  action
 
namespace  action_type
 
namespace  detail
 
namespace  nargs
 
namespace  util
 

Classes

class  argument
 Represents a command-line argument, either positional or optional. More...
 
class  argument_group
 Represents a group of arguments. More...
 
struct  argument_parser_exception
 Base type for the argument parser functionality errors/exceptions. More...
 
struct  invalid_configuration
 Exception type used for invalid configuration of an argument parser or its arguments. More...
 
struct  lookup_failure
 Exception type used for element lookup errors. More...
 
struct  none_type
 A type representing the absence of a value. This type is used for arguments that should not store any values or as a fallback type for conditionally defined types. More...
 
struct  parsing_failure
 Exception type used for errors encountered during the argument parsing operation. More...
 
struct  type_error
 Exception type used for type-related errors. More...
 
struct  version
 A helper structure used to represent a program's version. More...
 

Typedefs

template<util::c_argument_value_type T = std::string>
using positional_argument = argument< argument_type::positional, T >
 Positional argument alias.
 
template<util::c_argument_value_type T = std::string>
using optional_argument = argument< argument_type::optional, T >
 Optional argument alias.
 

Enumerations

enum class  argument_type : bool { positional , optional }
 A discriminator type used to specify the type of an argument within the argon::argument class. More...
 
enum class  default_argument : std::uint8_t {
  p_input , p_output , o_help , o_version ,
  o_input , o_output , o_multi_input , o_multi_output
}
 The enumeration of default arguments provided by the library. More...
 
enum class  unknown_policy : std::uint8_t { fail , warn , ignore , as_values }
 The enumeration of policies for handling unknown arguments. More...
 

Functions

std::ostream & operator<< (std::ostream &os, const argument_parser &) noexcept
 

Typedef Documentation

◆ optional_argument

template<util::c_argument_value_type T = std::string>
using argon::optional_argument = typedef argument<argument_type::optional, T>

Optional argument alias.

Template Parameters
TThe value type accepted by the argument (defaults to std::string).
See also
argon::argument

Definition at line 775 of file argument.hpp.

◆ positional_argument

template<util::c_argument_value_type T = std::string>
using argon::positional_argument = typedef argument<argument_type::positional, T>

Positional argument alias.

Template Parameters
TThe value type accepted by the argument (defaults to std::string).
See also
argon::argument

Definition at line 767 of file argument.hpp.

Enumeration Type Documentation

◆ argument_type

A discriminator type used to specify the type of an argument within the argon::argument class.

Enumerator
positional 
optional 

Definition at line 29 of file argument.hpp.

◆ default_argument

enum class argon::default_argument : std::uint8_t
strong

The enumeration of default arguments provided by the library.

Enumerator
p_input 

A positional argument representing a single input file path. Equivalent to:

parser.add_positional_argument("input")
.help("Input file path");
util::callable_type< argon::action_type::observe, std::string > check_file_exists() noexcept
Returns an observe action which checks whether lower_bound file with the given name exists.
An observing value action specifier.
Definition types.hpp:24
p_output 

A positional argument representing a single output file path. Equivalent to:

parser.add_positional_argument("output")
.help("Output file path");
o_help 

An optional argument representing the program's help flag. Equivalent to:

parser.add_optional_argument<argon::none_type>("help")
.help("Display the help message");
argon::action_type::on_flag::type print_help(const argument_parser &parser, const std::optional< int > exit_code=std::nullopt, std::ostream &os=std::cout) noexcept
Returns an on-flag action which prints the argument parser's help message.
A type representing the absence of a value. This type is used for arguments that should not store any...
Definition types.hpp:20
o_version 

An optional argument representing the program's version flag. Equivalent to:

arg_parser.add_optional_argument<none_type>("version", "v")
arg_parser.print_version();
std::exit(EXIT_SUCCESS);
})
.help("Dsiplay program version info");
o_input 

A positional argument representing multiple input file paths. Equivalent to:

parser.add_positional_argument("input", "i")
.nargs(1ull)
.help("Input file path");
o_output 

A positional argument representing multiple output file paths. Equivalent to:

parser.add_positional_argument("output", "o")
.nargs(1ull)
.help("Output file path");
o_multi_input 

A positional argument representing multiple input file paths. Equivalent to:

parser.add_positional_argument("input", "i")
.nargs(argon::nargs::at_least(1ull))
.help("Input file path");
constexpr range at_least(const count_type n) noexcept
range class builder function. Creates a range [n, inf).
Definition range.hpp:128
o_multi_output 

A positional argument representing multiple output file paths. Equivalent to:

parser.add_positional_argument("output", "o")
.nargs(argon::nargs::at_least(1ull))
.help("Output file path");

Definition at line 37 of file argument_parser.hpp.

◆ unknown_policy

enum class argon::unknown_policy : std::uint8_t
strong

The enumeration of policies for handling unknown arguments.

Enumerator
fail 

Throw an exception when an unknown argument is encountered.

warn 

Issue a warning when an unknown argument is encountered.

ignore 

Ignore unknown arguments.

as_values 

Treat unknown arguments as positional values.

Definition at line 132 of file argument_parser.hpp.

Function Documentation

◆ operator<<()

std::ostream & argon::operator<< ( std::ostream &  os,
const argument_parser &   
)
noexcept