- * Copyright 2019 Philippe Proulx <pproulx@efficios.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
+ * argpar is a library which provides facilities for command-line
+ * argument parsing.
+ *
+ * Two APIs are available:
+ *
+ * Iterator API:
+ * Create a parsing iterator with argpar_iter_create(), then
+ * repeatedly call argpar_iter_parse_next() to access the parsing
+ * results, until one of:
+ *
+ * * There are no more arguments.
+ *
+ * * The argument parser encounters an error (for example, an
+ * unknown option).
+ *
+ * * You need to stop.
+ *
+ * This API provides more parsing control than the next one.
+ *
+ * Single call API:
+ * Call argpar_parse(), which parses the arguments until one of:
+ *
+ * * There are no more arguments.
+ *
+ * * It encounters an argument parsing error.
+ *
+ * argpar_parse() returns a single array of parsing results.
+ *
+ * Both methods parse the arguments `argv` of which the count is `argc`
+ * using the sentinel-terminated (use `ARGPAR_OPT_DESCR_SENTINEL`)
+ * option descriptor array `descrs`.
+ *
+ * argpar considers ALL the elements of `argv`, including the first one,
+ * so that you would typically pass `argc - 1` and `&argv[1]` from what
+ * main() receives.
+ *
+ * The argpar parsers support:
+ *
+ * * Short options without an argument, possibly tied together:
+ *
+ * -f -auf -n
+ *
+ * * Short options with argument:
+ *
+ * -b 45 -f/mein/file -xyzhello
+ *
+ * * Long options without an argument:
+ *
+ * --five-guys --burger-king --pizza-hut --subway
+ *
+ * * Long options with arguments:
+ *
+ * --security enable --time=18.56
+ *
+ * * Non-option arguments (anything else).
+ *
+ * The argpar parsers don't accept `-` or `--` as arguments. The latter
+ * means "end of options" for many command-line tools, but this library
+ * is all about keeping the order of the arguments, so it doesn't mean
+ * much to put them at the end. This has the side effect that a
+ * non-option argument cannot have the form of an option, for example if
+ * you need to pass the exact relative path `--component`. In that case,
+ * you would need to pass `./--component`. There's no generic way to
+ * escape `-` as of this version.
+ *
+ * Both argpar_iter_create() and argpar_parse() accept duplicate options
+ * (they produce one item for each instance).
+ *
+ * A returned parsing item has the type `struct argpar_item *`. Each
+ * item is to be casted to the appropriate type
+ * (`struct argpar_item_opt *` or `struct argpar_item_non_opt *`)
+ * depending on its `type` member.
+ *
+ * Both argpar_iter_create() and argpar_parse() produce the items in
+ * the same order that the arguments were parsed, including non-option
+ * arguments. This means, for example, that for:
+ *
+ * --hello --count=23 /path/to/file -ab --type file magie
+ *
+ * The produced items are, in this order:
+ *
+ * 1. Option item (`--hello`).
+ * 2. Option item (`--count` with argument `23`).
+ * 3. Non-option item (`/path/to/file`).
+ * 4. Option item (`-a`).
+ * 5. Option item (`-b`).
+ * 6. Option item (`--type` with argument `file`).
+ * 7. Non-option item (`magie`).