aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorLion Kortlepel <[email protected]>2026-01-22 23:18:16 +0100
committerLion Kortlepel <[email protected]>2026-01-22 23:18:16 +0100
commit2d2be7e2b38031f7cd826f78543b18a287423ad7 (patch)
tree2bf0eba1995000e8d95cffae4101486541ce6eeb /examples
parent36fdeca43eab4439a117d4c912f87e704eaa9cd5 (diff)
downloadargs-2d2be7e2b38031f7cd826f78543b18a287423ad7.tar.zst
args-2d2be7e2b38031f7cd826f78543b18a287423ad7.zip
fix!: reach 96% line coverage, add tests, fix bugs
Diffstat (limited to 'examples')
-rw-r--r--examples/basic_example.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/examples/basic_example.c b/examples/basic_example.c
new file mode 100644
index 0000000..293d5c5
--- /dev/null
+++ b/examples/basic_example.c
@@ -0,0 +1,17 @@
+#define LS_ARGS_IMPLEMENTATION
+#include "ls_args.h"
+
+int main(int argc, char** argv) {
+ ls_args args;
+ int help = 0;
+ const char* outfile = "out.txt";
+
+ 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);
+ if (!ls_args_parse(&args, argc, argv)) {
+ printf("Error: %s\n%s\n", args.last_error, ls_args_help(&args));
+ }
+ ls_args_free(&args);
+ return 0;
+}