YAAP - Yet Another Argument Parser
A simple commandline argument parser for C
|
file for all argparse functions More...
Functions | |
void | argparse_usage (struct arg_parse_ctx *ctx, char *program) |
forward declaration of function More... | |
int | argparse_add_flag (struct arg_parse_ctx *ctx, struct arg_flag *flag) |
forward declaration of function More... | |
int | argparse_help (void *ctx, void *user) |
wrapper function for calling argparse_usage from the -h arg_flag command line argument More... | |
struct arg_parse_ctx * | argparse_init () |
initialize the argparse context More... | |
void | argparse_free (struct arg_parse_ctx *ctx) |
free an arg_parse context (all memory will be freed) More... | |
int | argparse_add_command (struct arg_parse_ctx *ctx, struct arg_parse_cmd *cmd) |
add an arg_parse_cmd to the context for later parsing More... | |
int | argparse_add_string (struct arg_parse_ctx *ctx, struct arg_str *str) |
add an arg_str to the context for later parsing More... | |
int | argparse_add_int (struct arg_parse_ctx *ctx, struct arg_int *integer) |
add an arg_int to the context for later parsing More... | |
void | argparse_unknown_command (struct arg_parse_ctx *ctx, char *program, char *command) |
internal function to print usage information, if an unknown command has been found More... | |
int | argparse_parse (struct arg_parse_ctx *ctx, int argc, char **argv) |
parse the given commandline More... | |
file for all argparse functions
int argparse_add_command | ( | struct arg_parse_ctx * | ctx, |
struct arg_parse_cmd * | cmd | ||
) |
add an arg_parse_cmd to the context for later parsing
add a commandline command to the context
ctx | - the context the command should be added to |
cmd | - the command to add to the context |
int argparse_add_flag | ( | struct arg_parse_ctx * | ctx, |
struct arg_flag * | flag | ||
) |
int argparse_add_int | ( | struct arg_parse_ctx * | ctx, |
struct arg_int * | integer | ||
) |
add an arg_int to the context for later parsing
add a integer argument to the context
ctx | - the context the command should be added to |
integer | - the arg_int to add |
int argparse_add_string | ( | struct arg_parse_ctx * | ctx, |
struct arg_str * | str | ||
) |
void argparse_free | ( | struct arg_parse_ctx * | ctx | ) |
free an arg_parse context (all memory will be freed)
free the parsing context at program end
this function should be called at the end of the programm
ctx | - the arg_parse_ctx structure to free |
int argparse_help | ( | void * | ctx, |
void * | user | ||
) |
wrapper function for calling argparse_usage from the -h arg_flag command line argument
ctx | - the current yaap context |
user | - some user specific data in this case the command line arguments |
struct arg_parse_ctx* argparse_init | ( | ) |
initialize the argparse context
initialize parsing context
This function has to be called at every start of the programm and before any other argparse functions are called!!!
int argparse_parse | ( | struct arg_parse_ctx * | ctx, |
int | argc, | ||
char ** | argv | ||
) |
parse the given commandline
parse the given commandline in the context
ctx | - the arg parse context to use |
argc | - the argument count of the commandline |
argv | - the argument list of the commandline |
void argparse_unknown_command | ( | struct arg_parse_ctx * | ctx, |
char * | program, | ||
char * | command | ||
) |
internal function to print usage information, if an unknown command has been found
ctx | - the context for which to print the usage information |
program | - the program name the application was called with |
command | - the command found |
void argparse_usage | ( | struct arg_parse_ctx * | ctx, |
char * | program | ||
) |
forward declaration of function
internal function to print usage information, not exported to user
ctx | - the context for which to print the usage information |
program | - the program name the application was called with |