@@ -361,6 +361,114 @@ int main(int argc, char **argv)
361361</TabItem >
362362</Tabs >
363363
364+ ## // Variadic Positional
365+
366+ Access variadic positional arguments the same way as array collections:
367+
368+ <Tabs >
369+ <TabItem value =" variadic-direct " label =" Direct Access " default >
370+
371+ ``` c
372+ ARGUS_OPTIONS (
373+ options,
374+ HELP_OPTION(),
375+ POSITIONAL_MANY_STRING("files", HELP("Input files to process"),
376+ HINT("FILE..."),
377+ FLAGS(FLAG_UNIQUE | FLAG_SORTED)),
378+ )
379+
380+ int main(int argc, char ** argv)
381+ {
382+ argus_t argus = argus_init(options, "myapp", "1.0.0");
383+ argus_parse(&argus, argc, argv);
384+
385+ // Check if files were provided
386+ if (argus_is_set(&argus, "files")) {
387+ size_t count = argus_count(&argus, "files");
388+ argus_value_t * files = argus_get(&argus, "files").as_array;
389+
390+ printf("Processing %zu files:\n", count);
391+ for (size_t i = 0; i < count; i++) {
392+ printf(" %zu: %s\n", i + 1, files[ i] .as_string);
393+ }
394+ } else {
395+ printf("No files specified\n");
396+ }
397+
398+ argus_free(&argus);
399+ return 0;
400+ }
401+ ```
402+
403+ </TabItem>
404+ <TabItem value="variadic-iterator" label="Iterator Access">
405+
406+ ```c
407+ ARGUS_OPTIONS(
408+ options,
409+ HELP_OPTION(),
410+ POSITIONAL_MANY_STRING("files", HELP("Input files"), HINT("FILE...")),
411+ )
412+
413+ int main(int argc, char **argv)
414+ {
415+ argus_t argus = argus_init(options, "myapp", "1.0.0");
416+ argus_parse(&argus, argc, argv);
417+
418+ // Use iterator for clean traversal
419+ argus_array_it_t it = argus_array_it(&argus, "files");
420+
421+ printf("Files to process:\n");
422+ while (argus_array_next(&it)) {
423+ printf(" - %s\n", it.value.as_string);
424+ process_file(it.value.as_string);
425+ }
426+
427+ argus_free(&argus);
428+ return 0;
429+ }
430+ ```
431+
432+ </TabItem >
433+ <TabItem value =" variadic-helper " label =" Helper Functions " >
434+
435+ ``` c
436+ ARGUS_OPTIONS (
437+ options,
438+ HELP_OPTION(),
439+ POSITIONAL_MANY_INT("numbers", HELP("Numbers to process"), HINT("NUM...")),
440+ )
441+
442+ int main(int argc, char ** argv)
443+ {
444+ argus_t argus = argus_init(options, "myapp", "1.0.0");
445+ argus_parse(&argus, argc, argv);
446+
447+ // Access specific elements by index
448+ int first = argus_array_get(&argus, "numbers", 0).as_int;
449+ int second = argus_array_get(&argus, "numbers", 1).as_int;
450+
451+ if (first) printf("First number: %d\n", first);
452+ if (second) printf("Second number: %d\n", second);
453+
454+ // Get total count
455+ size_t total = argus_count(&argus, "numbers");
456+ printf("Total numbers: %zu\n", total);
457+
458+ argus_free(&argus);
459+ return 0;
460+ }
461+ ```
462+
463+ </TabItem>
464+ </Tabs>
465+
466+ **Important notes:**
467+ - Variadic positionals use the same access functions as array options
468+ - Always check `argus_is_set()` before accessing since they accept zero values
469+ - Use `argus_count()` to get the number of values provided
470+ - Iterator pattern is most efficient for processing all values
471+
364472## // Subcommand Access
365473
366474In subcommand context, access values using path notation or relative names:
@@ -576,6 +684,8 @@ FILE *f = fopen(output, "w"); // output might be NULL!
576684| **Check if set** | `argus_is_set()` | `if (argus_is_set(&argus, "output"))` |
577685| **Array elements** | `argus_array_get()` | `argus_array_get(&argus, "tags", 0)` |
578686| **Array iteration** | `argus_array_it()` | `while (argus_array_next(&it))` |
687+ | **Variadic positional** | `argus_get().as_array` | `argus_get(&argus, "files").as_array` |
688+ | **Variadic iteration** | `argus_array_it()` | `while (argus_array_next(&it))` |
579689| **Map lookup** | `argus_map_get()` | `argus_map_get(&argus, "env", "USER")` |
580690| **Map iteration** | `argus_map_it()` | `while (argus_map_next(&it))` |
581691| **Subcommand relative** | `argus_get()` | `argus_get(argus, "file").as_string` |
0 commit comments