Banjo API 1.1.0-alpha
Low-level C99 game development API
Loading...
Searching...
No Matches
cli.h
Go to the documentation of this file.
1
50#ifndef BJ_CLI_H
51#define BJ_CLI_H
52
53#include <banjo/api.h>
54#include <banjo/error.h>
55
56struct bj_cli;
57struct bj_cli_argument;
58
82 const struct bj_cli* parser,
83 const struct bj_cli_argument* arg,
84 const char* value,
85 void* dest,
86 struct bj_error** error
87);
88
160 const char* name;
164 const char* help;
166 const char* metavar;
170 void* dest;
177};
178
185struct bj_cli {
186 const char* prog;
187 const char* description;
188 const char* epilog;
191};
192
228 struct bj_cli* parser,
229 int argc,
230 char* argv[],
231 struct bj_error** error
232);
233
254 const struct bj_cli* parser,
255 struct bj_error** error
256);
257
270 const struct bj_cli* parser
271);
272
298 const struct bj_cli* parser,
299 char* buffer,
300 size_t buffer_size
301);
302
322 const struct bj_cli* parser,
323 const struct bj_cli_argument* arg,
324 const char* value,
325 void* dest,
326 struct bj_error** error
327);
328
350 const struct bj_cli* parser,
351 const struct bj_cli_argument* arg,
352 const char* value,
353 void* dest,
354 struct bj_error** error
355);
356
379 const struct bj_cli* parser,
380 const struct bj_cli_argument* arg,
381 const char* value,
382 void* dest,
383 struct bj_error** error
384);
385
408 const struct bj_cli* parser,
409 const struct bj_cli_argument* arg,
410 const char* value,
411 void* dest,
412 struct bj_error** error
413);
414
437 const struct bj_cli* parser,
438 const struct bj_cli_argument* arg,
439 const char* value,
440 void* dest,
441 struct bj_error** error
442);
443
462 const struct bj_cli* parser,
463 const struct bj_cli_argument* arg,
464 const char* value,
465 void* dest,
466 struct bj_error** error
467);
468
469#endif // BJ_CLI_H
General-purpose definitions for Banjo API.
Recoverable error handling.
const char * help
Help message shown in usage output.
Definition cli.h:164
bj_cli_action_fn action
Callback to parse/store argument value.
Definition cli.h:173
const char * epilog
Text displayed after argument list.
Definition cli.h:188
int required
Set to 1 if positional argument is mandatory.
Definition cli.h:176
char shortname
Short option name (e.g., 'o' for -o).
Definition cli.h:162
const char * name
Long option name (e.g., "file" for --file).
Definition cli.h:160
const char * prog
Program name; if 0, bj_parse_cli sets it to argv[0].
Definition cli.h:186
size_t arguments_len
Number of arguments in the parser.
Definition cli.h:189
const char * description
Description text displayed before argument list.
Definition cli.h:187
struct bj_cli_argument * arguments
Pointer to array of argument descriptors.
Definition cli.h:190
const char * metavar
Placeholder for argument value in help output, printed in capitals.
Definition cli.h:166
void * dest
Pointer to store parsed value.
Definition cli.h:170
bj_bool bj_store_cli_cstring(const struct bj_cli *parser, const struct bj_cli_argument *arg, const char *value, void *dest, struct bj_error **error)
Store string argument value.
bj_bool bj_store_cli_int(const struct bj_cli *parser, const struct bj_cli_argument *arg, const char *value, void *dest, struct bj_error **error)
Store int argument value.
bj_bool(* bj_cli_action_fn)(const struct bj_cli *parser, const struct bj_cli_argument *arg, const char *value, void *dest, struct bj_error **error)
Callback function prototype for argument value processing.
Definition cli.h:81
void bj_print_cli_help(const struct bj_cli *parser)
Print the help message to standard output.
bj_bool bj_store_cli_double(const struct bj_cli *parser, const struct bj_cli_argument *arg, const char *value, void *dest, struct bj_error **error)
Store double argument value.
bj_bool bj_store_cli_bool(const struct bj_cli *parser, const struct bj_cli_argument *arg, const char *value, void *dest, struct bj_error **error)
Store boolean argument value.
size_t bj_get_cli_help_string(const struct bj_cli *parser, char *buffer, size_t buffer_size)
Get help message as a string for custom output.
bj_bool bj_parse_cli(struct bj_cli *parser, int argc, char *argv[], struct bj_error **error)
Parse command-line arguments according to parser configuration.
bj_bool bj_validate_cli(const struct bj_cli *parser, struct bj_error **error)
Check for configuration errors in the parser.
bj_bool bj_print_cli_help_action(const struct bj_cli *parser, const struct bj_cli_argument *arg, const char *value, void *dest, struct bj_error **error)
Print help argument action.
bj_bool bj_store_cli_uint(const struct bj_cli *parser, const struct bj_cli_argument *arg, const char *value, void *dest, struct bj_error **error)
Store unsigned int argument value.
Parser context and argument list descriptor.
Definition cli.h:185
Descriptor for a single command line argument.
Definition cli.h:159
struct bj_error bj_error
Definition api.h:348
#define BANJO_EXPORT
Definition api.h:179
uint32_t bj_bool
Boolean type used throughout the Banjo API.
Definition api.h:264