aboutsummaryrefslogtreecommitdiff
path: root/examples/basic_example.c
diff options
context:
space:
mode:
Diffstat (limited to 'examples/basic_example.c')
-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;
+}