libGimbal 0.2.0
C17-Based Extended Standard Library and Cross-Language Runtime Framework
Loading...
Searching...
No Matches
gimbal_cmd_parser.h File Reference

Go to the source code of this file.

Data Structures

struct  GblCmdArg
 
struct  GblCmdParserClass
 
struct  GblCmdParser
 

Macros

Type System

Type UUID and cast operators

#define GBL_CMD_PARSER_TYPE
 
#define GBL_CMD_PARSER(self)
 
#define GBL_CMD_PARSER_CLASS(klass)
 
#define GBL_CMD_PARSER_CLASSOF(self)
 

Functions

GblType GblCmdParser_type (void)
 
Lifetime Management

Methods for controlling lifetime of a GblCmdParser

GblCmdParser * GblCmdParser_create (void)
 
GblRefCount GblCmdParser_unref (GblCmdParser *pSelf)
 
Parsing

Methods for parsing arguments or managing parsed values

GblStringRef * GblCmdParser_executable (const GblCmdParser *pSelf)
 
const GblStringList * GblCmdParser_unknownOptions (const GblCmdParser *pSelf)
 
GblBool GblCmdParser_helpRequested (const GblCmdParser *pSelf)
 
GBL_RESULT GblCmdParser_formatHelp (const GblCmdParser *pSelf, GblStringBuffer *pBuffer)
 
GBL_RESULT GblCmdParser_parse (GblCmdParser *pSelf, GblStringList *pArgs)
 

Detailed Description

Modular command-line argument parser.

Todo
More descriptive errors and version options, use virtual methods for customization points, implement signals for events (probably), process(..) top-level method for handling exiting upon failure, version, or help.
Author
2023, 2026 Falco Girgis
2026 Agustín Bellagamba

Definition in file gimbal_cmd_parser.h.

Macro Definition Documentation

◆ GBL_CMD_PARSER_TYPE

#define GBL_CMD_PARSER_TYPE

Type UUID of GblCmdParser.

Definition at line 25 of file gimbal_cmd_parser.h.

◆ GBL_CMD_PARSER

#define GBL_CMD_PARSER ( self)

Function-style GblInstance cast.

Definition at line 26 of file gimbal_cmd_parser.h.

◆ GBL_CMD_PARSER_CLASS

#define GBL_CMD_PARSER_CLASS ( klass)

Function-style GblClass cast.

Definition at line 27 of file gimbal_cmd_parser.h.

◆ GBL_CMD_PARSER_CLASSOF

#define GBL_CMD_PARSER_CLASSOF ( self)

Get a GblCmdParserClass from GblInstance.

Definition at line 28 of file gimbal_cmd_parser.h.

Function Documentation

◆ GblCmdParser_type()

GblType GblCmdParser_type ( void )

Returns the GblType UUID associated with GblCmdParser.

◆ GblCmdParser_create()

GblCmdParser * GblCmdParser_create ( void )

Creates a GblCmdParser object, initializes it, and returns a pointer to it.

◆ GblCmdParser_unref()

GblRefCount GblCmdParser_unref ( GblCmdParser * pSelf)

Unreferences a GblCmdParser, destroying it if it's the last one, returning the remaining reference count.

◆ GblCmdParser_executable()

GblStringRef * GblCmdParser_executable ( const GblCmdParser * pSelf)

After parsing, returns a GblStringRef to the name of the current executable (first positional argument)

◆ GblCmdParser_unknownOptions()

const GblStringList * GblCmdParser_unknownOptions ( const GblCmdParser * pSelf)

After parsing, retuns a GblStringList to the internally maintained list of unknown command-line options.

◆ GblCmdParser_helpRequested()

GblBool GblCmdParser_helpRequested ( const GblCmdParser * pSelf)

Returns whether the last parse requested –help or -h, so the caller can display help and skip execution.

◆ GblCmdParser_formatHelp()

GBL_RESULT GblCmdParser_formatHelp ( const GblCmdParser * pSelf,
GblStringBuffer * pBuffer )

Replaces a constructed buffer with help generated from option groups and positional arguments.

◆ GblCmdParser_parse()

GBL_RESULT GblCmdParser_parse ( GblCmdParser * pSelf,
GblStringList * pArgs )

Parses the list of arguments given by pArgs, populating internal structures, and returning the result.