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.c23
1 files changed, 21 insertions, 2 deletions
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;
}