From 1f51309907acb1bed6e588961ccb4a6a792b85c0 Mon Sep 17 00:00:00 2001 From: Lion Kortlepel Date: Sun, 1 Feb 2026 12:34:45 +0000 Subject: feat!: break api by removing `n` from positionals, implement help string --- examples/basic_example.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'examples/basic_example.c') diff --git a/examples/basic_example.c b/examples/basic_example.c index 293d5c5..2f77b6c 100644 --- a/examples/basic_example.c +++ b/examples/basic_example.c @@ -5,13 +5,32 @@ int main(int argc, char** argv) { ls_args args; int help = 0; const char* outfile = "out.txt"; + const char* infile; + const char* testfile; ls_args_init(&args); ls_args_bool(&args, &help, "h", "help", "Prints help", 0); - ls_args_string(&args, &outfile, "o", "out", "Specify the outfile, default 'out.txt'", 0); + ls_args_string(&args, &outfile, "o", "out", + "Specify the outfile, default 'out.txt'", 0); + ls_args_pos_string(&args, &infile, "Input file", LS_ARGS_REQUIRED); + ls_args_pos_string(&args, &testfile, "Test file", 0); if (!ls_args_parse(&args, argc, argv)) { - printf("Error: %s\n%s\n", args.last_error, ls_args_help(&args)); + printf("Error: %s\n", args.last_error); + puts(ls_args_help(&args)); + ls_args_free(&args); + return 1; } + + if (help) { + puts(ls_args_help(&args)); + ls_args_free(&args); + return 0; + } + + printf("Got input file: %s\n", infile); + printf("Got output file: %s\n", outfile); + printf("Got test file: %s\n", testfile); + ls_args_free(&args); return 0; } -- cgit