Making my parsing library I’ve decided to have two parse functions
parseArgs(gpa: Allocator, definition: anytype, args: []const []const u8, ...) for a very freestyle parsing. As I have to iterate over the arguments lots of times, the function requires args to be provided as in const args = init.minimal.args.toSlice(init.gpa). To test it is no problem, I just declare a const args = &[_][]u8{ "utility", "arg1", "--flag" } and I test it.
A POSIX style parseArgsPosix(definition: anytype, args: *Args.Iterator, ...). Here is the question:
Is there someway to create the Args.Iterator object in the test itself given a string as it would be obtained from argv? Like this:
I’ve take a look at the std.process.Args, and I’ve found the IteratorGeneral, but that’s not a *Args.Iterator type so it’s not exactly what I am looking for, and if would like to avoid changing the type of args to anytype and maybe both would work? Also, if to ask for an Iterator is not what I should do, feel free to tell me