25int main(
int argc,
char* argv[]) {
29 const char* input_file =
"default.txt";
30 const char* output_file = NULL;
33 double tolerance = 0.001;
34 int enable_feature = 0;
51 .help =
"Show this help message and exit",
60 .help =
"Enable verbose output",
69 .help =
"Input file path",
80 .help =
"Number of iterations to perform",
90 .help =
"Number of worker threads",
100 .help =
"Tolerance level for calculations",
109 .name =
"enable-feature",
110 .help =
"Enable experimental feature (true/false)",
113 .dest = &enable_feature
120 .help =
"Output file path (optional)",
123 .dest = &output_file,
133 .prog =
"example_cli",
134 .description =
"Example program demonstrating Banjo's argument parsing.\n"
135 "Shows flags, named options, type conversion, and positional arguments.",
136 .epilog =
"Examples:\n"
137 " example_cli -v -i data.txt output.txt\n"
138 " example_cli --count 10 --threads 8 --tolerance 0.01\n"
139 " example_cli -vci input.txt -t 4 result.txt",
140 .arguments_len =
sizeof(args) /
sizeof(args[0]),
157 bj_info(
"=== Parsed Arguments ===");
158 bj_info(
"Verbose: %s", verbose ?
"enabled" :
"disabled");
159 bj_info(
"Input File: %s", input_file);
161 bj_info(
"Threads: %d", threads);
162 bj_info(
"Tolerance: %.6f", tolerance);
163 bj_info(
"Feature Enabled: %s", enable_feature ?
"yes" :
"no");
166 bj_info(
"Output File: %s", output_file);
168 bj_info(
"Output File: (not specified)");
172 bj_info(
"=== Simulating Work ===");
174 for (
int i = 0; i < count; i++) {
175 bj_info(
"Processing iteration %d/%d...", i + 1, count);
178 bj_info(
"Processing %d iterations...", count);
int main(int argc, char *argv[])
POSIX/GNU-like command-line argument parser.
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.
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.
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_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.
Parser context and argument list descriptor.
Descriptor for a single command line argument.
#define bj_info(...)
Log a message using the BJ_LOG_INFO level.
Logging utility functions.
Portable main() replacement with platform-aware entry shim.
All memory-related functions, including custom allocators.