Banjo API 0.0.1
C99 game development API
Loading...
Searching...
No Matches
cli.h
Go to the documentation of this file.
1
37#ifndef BJ_CLI_H
38#define BJ_CLI_H
39
40#include <banjo/api.h>
41#include <banjo/error.h>
42
43struct bj_cli;
44struct bj_cli_argument;
45
69 const struct bj_cli* parser,
70 const struct bj_cli_argument* arg,
71 const char* value,
72 void* dest,
73 struct bj_error** error
74);
75
140 const char* name;
144 const char* help;
146 const char* metavar;
148 void* dest;
153};
154
161struct bj_cli {
162 const char* prog;
163 const char* description;
164 const char* epilog;
167};
168
198 struct bj_cli* parser,
199 int argc,
200 char* argv[],
201 struct bj_error** error
202);
203
223 const struct bj_cli* parser,
224 struct bj_error** error
225);
226
238 const struct bj_cli* parser
239);
240
260 const struct bj_cli* parser,
261 char* buffer,
262 size_t buffer_size
263);
264
280 const struct bj_cli* parser,
281 const struct bj_cli_argument* arg,
282 const char* value,
283 void* dest,
284 struct bj_error** error
285);
286
304 const struct bj_cli* parser,
305 const struct bj_cli_argument* arg,
306 const char* value,
307 void* dest,
308 struct bj_error** error
309);
310
328 const struct bj_cli* parser,
329 const struct bj_cli_argument* arg,
330 const char* value,
331 void* dest,
332 struct bj_error** error
333);
334
352 const struct bj_cli* parser,
353 const struct bj_cli_argument* arg,
354 const char* value,
355 void* dest,
356 struct bj_error** error
357);
358
376 const struct bj_cli* parser,
377 const struct bj_cli_argument* arg,
378 const char* value,
379 void* dest,
380 struct bj_error** error
381);
382
398 const struct bj_cli* parser,
399 const struct bj_cli_argument* arg,
400 const char* value,
401 void* dest,
402 struct bj_error** error
403);
404
405#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:144
bj_cli_action_fn action
Callback to parse/store argument value.
Definition cli.h:150
const char * epilog
Text displayed after argument list.
Definition cli.h:164
int required
Set to 1 if positional argument is mandatory.
Definition cli.h:152
char shortname
Short option name (e.g., 'o' for -o).
Definition cli.h:142
const char * name
Long option name (e.g., "file" for --file).
Definition cli.h:140
const char * prog
Program name; if 0, argv[0] is used.
Definition cli.h:162
size_t arguments_len
Number of arguments in the parser.
Definition cli.h:165
const char * description
Description text displayed before argument list.
Definition cli.h:163
struct bj_cli_argument * arguments
Pointer to array of argument descriptors.
Definition cli.h:166
const char * metavar
Placeholder for argument value in help output.
Definition cli.h:146
void * dest
Pointer to store parsed value.
Definition cli.h:148
bj_bool bj_cli_parse(struct bj_cli *parser, int argc, char *argv[], struct bj_error **error)
Parse command-line arguments according to parser configuration.
bj_bool bj_cli_store_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.
size_t bj_cli_get_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_cli_store_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_cli_validate(const struct bj_cli *parser, struct bj_error **error)
Check for configuration errors in the parser.
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:68
bj_bool bj_cli_store_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_store_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.
bj_bool bj_cli_print_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.
void bj_cli_print_help(const struct bj_cli *parser)
Print help message using Banjo's logging system.
bj_bool bj_cli_store_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:161
Descriptor for a single command line argument.
Definition cli.h:139
#define BANJO_EXPORT
Definition api.h:155
uint32_t bj_bool
Boolean type used throughout the Banjo API.
Definition api.h:249
Error structure.
Definition error.h:131