aboutsummaryrefslogtreecommitdiff
path: root/ls_args.h
diff options
context:
space:
mode:
authorLion Kortlepel <[email protected]>2026-02-01 12:41:07 +0000
committerLion Kortlepel <[email protected]>2026-02-01 12:41:07 +0000
commita29480c901a92a1b1891b4edc3239f8d997a3f9d (patch)
tree3e4efad7daa65163fd2d653bb2660ee571b47ccf /ls_args.h
parentb6a9555abeab565d7bf1a9b3e9840eefe6644674 (diff)
downloadargs-a29480c901a92a1b1891b4edc3239f8d997a3f9d.tar.zst
args-a29480c901a92a1b1891b4edc3239f8d997a3f9d.zip
fix: clarify and add test for positional required argsv2.1
Diffstat (limited to 'ls_args.h')
-rw-r--r--ls_args.h14
1 files changed, 12 insertions, 2 deletions
diff --git a/ls_args.h b/ls_args.h
index 26be3c2..b66c462 100644
--- a/ls_args.h
+++ b/ls_args.h
@@ -1,6 +1,7 @@
-/* Lion's Standard (LS) ANSI C commandline argument parser.
+/* Lion's Standard (LS) ANSI C commandline argument parser with included help
+ * renderer.
*
- * Version: 2.0
+ * Version: 2.1
* Website: https://libls.org
* Repo: https://github.com/libls/args
* SPDX-License-Identifier: MIT
@@ -22,6 +23,8 @@
* - Stop signals: `--` (everything after this is positional arguments)
* - Positional arguments: `input.txt output.txt`
*
+ * Includes a help renderer.
+ *
* ==== 2. HOW TO USE ====
*
* ls_args, like all LS libraries, is a header-only library in a single file.
@@ -30,18 +33,22 @@
*
* Then include and use it.
*
+ * Define LS_ARGS_IMPLEMENTATION in exactly one source file before the include.
+ *
* Example:
*
* #include <ls_args.h>
* // ...
* ls_args args;
* int help = 0;
+ * const char* infile;
* 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);
+ * ls_args_pos_string(&args, &infile, "input file")
* if (!ls_args_parse(&args, argc, argv)) {
* printf("Error: %s\n%s\n", args.last_error,
* ls_args_help(&args));
@@ -193,6 +200,9 @@ int ls_args_string(ls_args*, const char** val, const char* short_opt,
*
* The first call to this function declares the argument for n=0, the next for
* n=1, and so on.
+ *
+ * If the first positional isn't LS_ARGS_REQUIRED, but the second is,
+ * effectively both are required.
*/
int ls_args_pos_string(
ls_args*, const char** val, const char* name, ls_args_mode mode);