Banjo API 1.0.0-rc.2
Low-level C99 game development API
Loading...
Searching...
No Matches
cli.h
Go to the documentation of this file.
1
49#ifndef BJ_CLI_H
50#define BJ_CLI_H
51
52#include <banjo/api.h>
53#include <banjo/error.h>
54
55struct bj_cli;
56struct bj_cli_argument;
57
81 const struct bj_cli* parser,
82 const struct bj_cli_argument* arg,
83 const char* value,
84 void* dest,
85 struct bj_error** error
86);
87
152 const char* name;
156 const char* help;
158 const char* metavar;
160 void* dest;
165};
166
173struct bj_cli {
174 const char* prog;
175 const char* description;
176 const char* epilog;
179};
180
210 struct bj_cli* parser,
211 int argc,
212 char* argv[],
213 struct bj_error** error
214);
215
235 const struct bj_cli* parser,
236 struct bj_error** error
237);
238
250 const struct bj_cli* parser
251);
252
272 const struct bj_cli* parser,
273 char* buffer,
274 size_t buffer_size
275);
276
292 const struct bj_cli* parser,
293 const struct bj_cli_argument* arg,
294 const char* value,
295 void* dest,
296 struct bj_error** error
297);
298
316 const struct bj_cli* parser,
317 const struct bj_cli_argument* arg,
318 const char* value,
319 void* dest,
320 struct bj_error** error
321);
322
340 const struct bj_cli* parser,
341 const struct bj_cli_argument* arg,
342 const char* value,
343 void* dest,
344 struct bj_error** error
345);
346
364 const struct bj_cli* parser,
365 const struct bj_cli_argument* arg,
366 const char* value,
367 void* dest,
368 struct bj_error** error
369);
370
388 const struct bj_cli* parser,
389 const struct bj_cli_argument* arg,
390 const char* value,
391 void* dest,
392 struct bj_error** error
393);
394
410 const struct bj_cli* parser,
411 const struct bj_cli_argument* arg,
412 const char* value,
413 void* dest,
414 struct bj_error** error
415);
416
417#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:156
bj_cli_action_fn action
Callback to parse/store argument value.
Definition cli.h:162
const char * epilog
Text displayed after argument list.
Definition cli.h:176
int required
Set to 1 if positional argument is mandatory.
Definition cli.h:164
char shortname
Short option name (e.g., 'o' for -o).
Definition cli.h:154
const char * name
Long option name (e.g., "file" for --file).
Definition cli.h:152
const char * prog
Program name; if 0, argv[0] is used.
Definition cli.h:174
size_t arguments_len
Number of arguments in the parser.
Definition cli.h:177
const char * description
Description text displayed before argument list.
Definition cli.h:175
struct bj_cli_argument * arguments
Pointer to array of argument descriptors.
Definition cli.h:178
const char * metavar
Placeholder for argument value in help output.
Definition cli.h:158
void * dest
Pointer to store parsed value.
Definition cli.h:160
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:80
void bj_print_cli_help(const struct bj_cli *parser)
Print help message using Banjo's logging system.
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:173
Descriptor for a single command line argument.
Definition cli.h:151
struct bj_error bj_error
Definition api.h:333
#define BANJO_EXPORT
Definition api.h:163
uint32_t bj_bool
Boolean type used throughout the Banjo API.
Definition api.h:257