-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
examples/macros.rs failed when running without arguments #10
Comments
This is the intended behavior of sarge: notice how there's no Perhaps I could change the panic message, or change the example to put print a message rather than panicking? |
Hmm, when cleaning up the |
Actually I use #ok, but maybe #err is what I need. I will look into this.
I am writing a CLI Application where 3 string option arguments are mandatory and when they are not given the application shall print a failure message together with the help output. Furthermore I am not a fan of code which panics. ;)
Maybe there is a failure which led to this panic. Thank you for your investigation! |
Unfortunately, there's not much I can do about error messages: besides some panics, error handling is outside the purview of sarge, so
The issue isn't a panic; it's that subsequent lines of documentation don't get printed with indentation. I really can't figure out why, the expanded code seems like it ought to work just fine.
Notably, if you give an argument that has no default value (for example, bools always default to false if not passed, while strings have no default) no tag, and it doesn't get passed, sarge has no option but to panic. What else could it do? You told it not you give you an error, so the only thing it can do is panic on the spot. |
Hmm, I understand. Think that my not understanding is because I'm pretty new to rust and don't know how the code and macros works. Thank you! |
Happy to help! Note that for string arguments, you probably want |
I have another behavior that possibly could be fixed.
When running the example examples/macros.rs and not providing any arguments (i.e. not providing the -n argument) the application panicks instead of printing the help message.
I think the application crashes when try to execute the macro in line 426
The get function which is called by this macro works, but after that something weired is going on I do not understand. ;)
The first argument -h is processed correctly from __parse_arg and the .get function. This returns ArgumentRef.default_value as ok. After this the next call from __pars_arg crashes.
Failure message at this line is: "Tried to unwrap argument that wasn't passed"
The text was updated successfully, but these errors were encountered: