71 #define ARGPARSE_INITIAL_COMMAND_NR 5 73 #define to_argbase(ptr) ((struct arg_base *) ptr) 74 #define to_cmd(ptr) ((struct arg_parse_cmd *)ptr) 75 #define to_str(ptr) ((struct arg_str *)ptr) 76 #define to_flag(ptr) ((struct arg_flag *) ptr) 77 #define to_int(ptr) ((struct arg_int *) ptr) 108 int (*cb)(
int argc,
char **argv);
131 int (*cb)(
void *ctx,
void *userdata);
const char * description
short description of the command
Definition: argparse.h:107
const char * long_flag
multi char flag identifying the argument, ignore if NULL
Definition: argparse.h:117
int argparse_add_string(struct arg_parse_ctx *ctx, struct arg_str *str)
add a string argument to the context
Definition: argparse.c:154
char * value
memory already allocated for the string parameter
Definition: argparse.h:118
void argparse_free(struct arg_parse_ctx *ctx)
free the parsing context at program end
Definition: argparse.c:94
int mandatory
is the argument mandatory
Definition: argparse.h:95
structure representing a string command line argument
Definition: argparse.h:114
const char * description
short description of the argument
Definition: argparse.h:141
void ** arguments
array for all argparse elementsdd
Definition: argparse.h:152
an argument with a string parameter (-t hallo, –title=hallo)
Definition: argparse.h:85
char short_flag
one char flag identifying the argument, ignored if NULL
Definition: argparse.h:128
structure representing a command
Definition: argparse.h:102
int nr_arguments
how many arguments are currently registered
Definition: argparse.h:153
const char * command
the name of the command on the commandline, no spaces or special chars allowed, only ascii ...
Definition: argparse.h:106
const char * long_flag
multi char flag identifying the argument, ignore if NULL
Definition: argparse.h:140
struct arg_parse_ctx * argparse_init()
initialize parsing context
Definition: argparse.c:58
structure representing a simple flag command line argument
Definition: argparse.h:126
const char * description
short description of the argument
Definition: argparse.h:130
base structure for a command line argument
Definition: argparse.h:92
int argparse_add_flag(struct arg_parse_ctx *ctx, struct arg_flag *flag)
add a flag argument to the context
Definition: argparse.c:185
an argument with a integer parameter (-s 10, –size=10)
Definition: argparse.h:86
char short_flag
one char flag identifying the argument, ignored if NULL
Definition: argparse.h:116
int maxchars
the maximum number of chars for the string parameters
Definition: argparse.h:119
a simple flag like -v without additional parameter
Definition: argparse.h:84
int argparse_add_int(struct arg_parse_ctx *ctx, struct arg_int *integer)
add a integer argument to the context
Definition: argparse.c:216
char short_flag
one char flag identifying the argument, ignored if NULL
Definition: argparse.h:139
int argparse_parse(struct arg_parse_ctx *ctx, int argc, char **argv)
parse the given commandline in the context
Definition: argparse.c:322
structure representing a simple int command line argument
Definition: argparse.h:137
const char * long_flag
multi char flag identifying the argument, ignore if NULL
Definition: argparse.h:129
int * value
the value of the option
Definition: argparse.h:142
argtypes
supported argument types
Definition: argparse.h:82
int argparse_add_command(struct arg_parse_ctx *ctx, struct arg_parse_cmd *cmd)
add a commandline command to the context
Definition: argparse.c:124
const char * description
short description of the argument
Definition: argparse.h:120
structure for the argparse context, holding argparse specific data structures
Definition: argparse.h:150
a command argument like git uses it (git commit)
Definition: argparse.h:83
int no_command
if this is 1, the callback will be called if no command is given
Definition: argparse.h:105
enum argtypes type
type of the argument
Definition: argparse.h:94