Bash++
Bash++ compiler internal documentation
Namespaces | Classes | Enumerations
XGetOpt Namespace Reference

Namespaces

namespace  Helpers
 

Classes

struct  Option
 Compile-time representation of a command-line option. More...
 
class  OptionParser
 Parses command-line arguments based on a set of defined options. More...
 
struct  OptionRemainder
 
class  OptionSequence
 Represents a sequence of parsed options and non-option arguments. More...
 
class  ParsedOption
 Represents a parsed command-line option and its associated argument (if any) More...
 

Enumerations

enum  ArgumentRequirement : uint8_t { NoArgument = 0 , RequiredArgument = 1 , OptionalArgument = 2 }
 Specifies whether an option requires an argument, has an optional argument, or has no argument. More...
 
enum  StopCondition { AllOptions , BeforeFirstNonOptionArgument , AfterFirstNonOptionArgument , BeforeFirstError }
 Specifies when to stop parsing options. More...
 

Detailed Description

Copyright (C) 2025-2026 Andrew S. Rightenburg

XGetOpt is a C++20 compile-time wrapper around getopt_long for parsing command-line options. It allows defining options at compile-time and automatically generates help strings without runtime overhead.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

Enumeration Type Documentation

◆ ArgumentRequirement

Specifies whether an option requires an argument, has an optional argument, or has no argument.

Enumerator
NoArgument 
RequiredArgument 
OptionalArgument 

◆ StopCondition

Specifies when to stop parsing options.

An explanation of each:

  • AllOptions: Parse all options until the end of the argument list
  • BeforeFirstNonOptionArgument: Stop parsing when the first non-option argument is encountered The non-option argument and any subsequent arguments are left unparsed
  • AfterFirstNonOptionArgument: Stop parsing after the first non-option argument is encountered The first non-option argument is included in the parsed results, but any subsequent arguments are left unparsed
  • BeforeFirstError: Stop parsing when the first error is encountered (unknown option or missing required argument) The offending option is not included in the parsed results, and it as well as any subsequent arguments are left unparsed
Enumerator
AllOptions 
BeforeFirstNonOptionArgument 
AfterFirstNonOptionArgument 
BeforeFirstError