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.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/examples/basic_example.c b/examples/basic_example.c
index 2f77b6c..43413f4 100644
--- a/examples/basic_example.c
+++ b/examples/basic_example.c
@@ -9,24 +9,24 @@ int main(int argc, char** argv) {
const char* testfile;
ls_args_init(&args);
+ args.help_description = "An example program to show how arguments work. "
+ "Provide an input file and optionally an output "
+ "file and test file and see what happens!";
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_pos_string(&args, &infile, "Input file", LS_ARGS_REQUIRED);
- ls_args_pos_string(&args, &testfile, "Test file", 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", args.last_error);
- puts(ls_args_help(&args));
+ if (help) {
+ puts(ls_args_help(&args));
+ } else {
+ printf("Error: %s\n", args.last_error);
+ }
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);