Required arguments
fretn opened this issue · comments
Now everything is optional, is there a possibility to make a flag required ?
for example
./myapp --server myapp.com
and when --server
flag is not passed the app throws an error.
or is this already possible and I'm just looking over it ?
I know I can go manually over all the flags and throw an error, but I wonder if there is an automatic way
No, there's not currently a way to mark a field as required.
Maybe we can add an additional item required
to the definition, like:
#[options(required, help = "host to connect", meta = "HOST")]
server: String,
If the flag is not present, returns something like:
gumdrop::Error::missing_required_flag("server")
I've just pushed a commit that implements a required
flag for options.
@fretn: If this satisfies your use case, feel free to close this issue. If not, further comments are welcome.
Can’t test until next week but it looks like what I needed. Great work.