-
-
Notifications
You must be signed in to change notification settings - Fork 747
Description
Consider the following hypothetical program invocations:
$ program --include=dir1 --exclude=*.avi$ program file1 -C dir2 file2 -C dir3 file3Both examples are not currently supported by std.getopt:
- In the first example, we lose the information of whether
--include=dir1was specified before--exclude=*.avi. As such, we would not be able to know if the user wants the program to act on.avifiles indir1. - In the second example, we lose the relative ordering of positional arguments and options, so we don't know which directory each file should be searched for.
The above examples are based on the CLI of real ubiquitous tools - see find(1), rsync(1), tar(1).
The first example is not supported because std.getopt acts on options in the order they are declared in the program, not the order they apprear on the command line. Thus, getopt(args, "include", ..., "exclude", ...) will process all --include arguments before any --exclude arguments.
The second example is not supported because std.getopt does not allow capturing the relative order of positional arguments with respect to options; the two are separated, losing ordering, with one being returned in the mutated args and the other in the passed ref-variable or predicate.
We need:
- an option to switch the processing order of arguments to be in the order they were specified on the command line
- a method of receiving positional arguments in-band with options (e.g. via a predicate).