ikskuh/zig-args

Implement support for obligatory values

Closed this issue · 2 comments

b-NC commented

Hi, I came across a use case for this library where it'd be useful if it could parse mandatory values that would be located at the end of the command :

For example if one makes a program that is processing the content of a file, it would be useful to be able tell the user he has to pass a path in order for the program to work;

It would also be useful having that system to have the last passed element in the command considered a specific element, for instance a path, that could be passed without hyphens

I have this stuff explicitly not in the library, as this is trivially implementable with if(result.positionals.len < 1) and other tools and configuring this behaviour is a lot more complex than just having a switch over result.positionals.len

It would also be useful having that system to have the last passed element in the command considered a specific element, for instance a path, that could be passed without hyphens

This is an OS/shell specific thing. If you pass a b, you'll receive two elements { "a", "b"}.
But receive the same if you pass a, then 100 spaces, then b

b-NC commented

I have this stuff explicitly not in the library, as this is trivially implementable with if(result.positionals.len < 1)

Yeah, that's what I ended up doing as well;

Thanks