-
Notifications
You must be signed in to change notification settings - Fork 22
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
Documentation should mention how to accept filenames as arguments. #15
Comments
gumdrop does not currently accept This is because the parser must check whether each string begins with the substring It may be possible to implement an internal gumdrop API that implements these operations atop the platform-specific Unix and Windows |
Just view OsStr as byte slice, then use something like
It should be documented then, with specific mention about filenames. What happens if one specifies a non-UTF8 argument? |
It would not be possible to implement this feature only on Unix, as it requires changing the public API to accept argument values as As to your last question, the functions |
In any case the limitation should be mentioned in the docs for current version. For example, example code blocks may include Bugs in handling of non-unicode filenames are easy to miss. |
What's the concrete issue here? At least on recent Rust versions, I'm able to parse arguments to e.g. |
Internally, All of the above assumes nothing has changed in the past few months (I'm pretty sure nothing has). |
...but as @murarth already pointed out, the arguments come in as Can you give concrete, minified examples (outside of
? |
You can avoid the issue by using You can easily break something that uses If you want a concrete example that doesn’t use |
Wouldn’t that have an analogous problem in that it would break parsing of Unicode |
Do you actually need to know that the argument is Unicode most of the time? If it’s a path that you use to open a file, you likely don’t. If it’s a command-line option, you can just use the The benefit of |
clap-rs/clap#1524 might be of interest. I made an |
For the record, this is the number-one reason why I'm not even considering switching from structopt to gumdrop to cut down the size of the template I use for writing little CLI utilities. I have mojibake'd paths on my drives that would panic something that assumes arguments are valid UTF-8. In fact, they revealed that Serde's (The same project also discovered that Serde panics on attempting to serialize the pre-epoch modification timestamps from an old floppy disk with mildly corrupted filesystem metadata.) |
A filename or path is not a
String
, butOsString
. I don't see any mention of OS strings in crate-level documentation for gumdrop.Also I see
parse(try_from_str
andparse(from_str
, but I don't see the exhausive list of what I can put intoparse(...)
. Is therefrom_os_str
?The text was updated successfully, but these errors were encountered: