|
ArgPar-C v1.0.0-build
Simple and powerful Argument Parser for C
|
#include <stdbool.h>#include "../../../vendor/cvec/inc/cvec/cvec.h"Go to the source code of this file.
Data Structures | |
| struct | APC_ArgInfo |
| struct | APC_ArgParser |
| struct | APC_RGB |
Macros | |
| #define | __APC_CPP_GUARD_CLOSE } |
| #define | __APC_CPP_GUARD_OPEN extern "C" { |
Enumerations | |
| enum | APC_RGB_Command { APC_RGB_Command_None , APC_RGB_Command_Reset , APC_RGB_Command_Bold , APC_RGB_Command_Italic , APC_RGB_Command_Underline } |
Functions | |
| char * | __apc_colorFormat (APC_ArgParser *argpar, const char *msg) |
| Format color;. | |
| APC_RGB | __apc_rgbToRGBStruct (const char *rgbStr) |
| Convert the default RGB format to a valid RGB struct and parse all extended commands. | |
| char * | __apc_setRGB (int r, int g, int b) |
| Convert RGB to ANSI escape code. | |
| bool | apc_add (APC_ArgParser *argpar, APC_ArgInfo info) |
| Setup Arg Information to the argpar. | |
| void | apc_destroy (APC_ArgParser *argpar) |
| Free all allocated data for argument parser. | |
| char * | apc_generateHelp (APC_ArgParser *argpar, const char *title, const char *topInfo, const char *lowerInfo) |
| Automatically generate help and pass it to the string to return. | |
| bool | apc_get (APC_ArgParser *argpar, const char *id) |
| Get if there is an argument present. | |
| APC_ArgParser | apc_init (int argc, char *argv[]) |
| Initialize parser with argc and argv from the main() function. | |
| APC_ArgInfo | apc_initInfo (void) |
| Initialize information for params. | |
| #define __APC_CPP_GUARD_CLOSE } |
Definition at line 10 of file APC_ArgParser.h.
| #define __APC_CPP_GUARD_OPEN extern "C" { |
Definition at line 9 of file APC_ArgParser.h.
| enum APC_RGB_Command |
| Enumerator | |
|---|---|
| APC_RGB_Command_None | |
| APC_RGB_Command_Reset | |
| APC_RGB_Command_Bold | |
| APC_RGB_Command_Italic | |
| APC_RGB_Command_Underline | |
Definition at line 18 of file APC_ArgParser.h.
| char * __apc_colorFormat | ( | APC_ArgParser * | argpar, |
| const char * | msg ) |
Format color;.
| argpar | Argument to format color and get data from |
| msg | Message to format |
Definition at line 199 of file APC_ArgParser.c.
References __apc_rgbToRGBStruct(), __apc_setRGB(), APC_RGB::__externalAction, APC_FREE, APC_RGB_Command_Bold, APC_RGB_Command_Italic, APC_RGB_Command_Reset, APC_RGB_Command_Underline, APC_STYLE_BOLD, APC_STYLE_ITALIC, APC_STYLE_RESET, APC_STYLE_UNDERLINE, APC_RGB::b, APC_ArgParser::enableColor, APC_RGB::g, and APC_RGB::r.
Referenced by apc_generateHelp().
| APC_RGB __apc_rgbToRGBStruct | ( | const char * | rgbStr | ) |
Convert the default RGB format to a valid RGB struct and parse all extended commands.
Definition at line 132 of file APC_ArgParser.c.
References APC_RGB::__externalAction, APC_RGB_Command_Bold, APC_RGB_Command_Italic, APC_RGB_Command_None, APC_RGB_Command_Reset, APC_RGB_Command_Underline, APC_RGB::b, APC_RGB::g, and APC_RGB::r.
Referenced by __apc_colorFormat().
| char * __apc_setRGB | ( | int | r, |
| int | g, | ||
| int | b ) |
Convert RGB to ANSI escape code.
| r | Red color |
| g | Green color |
| b | Blue color |
Definition at line 101 of file APC_ArgParser.c.
Referenced by __apc_colorFormat().
| bool apc_add | ( | APC_ArgParser * | argpar, |
| APC_ArgInfo | info ) |
Setup Arg Information to the argpar.
| argpar | Argument Parser to modify information from |
| info | Create information about the param |
Definition at line 48 of file APC_ArgParser.c.
References APC_ArgParser::args, APC_ArgInfo::id, and APC_ArgInfo::param.
Referenced by main().
| void apc_destroy | ( | APC_ArgParser * | argpar | ) |
Free all allocated data for argument parser.
| argpar | Argument parser to free from memory |
Definition at line 33 of file APC_ArgParser.c.
References APC_ArgInfo::aliases, and APC_ArgParser::args.
Referenced by main().
| char * apc_generateHelp | ( | APC_ArgParser * | argpar, |
| const char * | title, | ||
| const char * | topInfo, | ||
| const char * | lowerInfo ) |
Automatically generate help and pass it to the string to return.
| argpar | Argument parser to generate help from |
| title | Title of the help |
| topInfo | Top information (eg: Little intro of the tool) |
| lowerInfo | Lower information (eg: License, ...) |
Definition at line 301 of file APC_ArgParser.c.
References __apc_colorFormat(), APC_ArgInfo::aliases, APC_FREE, APC_STYLECOLOR_OPTIONAL, APC_STYLECOLOR_TITLE, APC_ArgParser::args, APC_ArgInfo::help, APC_ArgInfo::id, APC_ArgInfo::param, APC_ArgInfo::required, and APC_ArgInfo::sparam.
Referenced by main().
| bool apc_get | ( | APC_ArgParser * | argpar, |
| const char * | id ) |
Get if there is an argument present.
| argpar | Get parameters from argpar |
| id | ID to fetch |
Definition at line 61 of file APC_ArgParser.c.
References APC_ArgInfo::aliases, APC_ArgParser::argc, APC_ArgParser::args, APC_ArgParser::argv, APC_ArgInfo::id, APC_ArgInfo::param, and APC_ArgInfo::sparam.
Referenced by main().
| APC_ArgParser apc_init | ( | int | argc, |
| char * | argv[] ) |
Initialize parser with argc and argv from the main() function.
| argc | Number of arguments |
| argv | Argument values |
Definition at line 12 of file APC_ArgParser.c.
References APC_ArgParser::argc, APC_ArgParser::args, APC_ArgParser::argv, and APC_ArgParser::enableColor.
Referenced by main().
| APC_ArgInfo apc_initInfo | ( | void | ) |
Initialize information for params.
Definition at line 24 of file APC_ArgParser.c.
References APC_ArgInfo::aliases, and APC_ArgInfo::required.
Referenced by main().