-
Notifications
You must be signed in to change notification settings - Fork 53
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
tuftool: support filepaths in addition to file:// urls #348
Comments
IMO, we should support raw paths under windows; after all, they are already supported under *nix, but I'll admit, this is a complex problem. |
Maybe we could detect when no protocol is found, (like raw paths) and convert them to file:// paths without changing the rest of the code, I mean, for the rest of the tool, it would be just like a file:// URL was given, and the execution could go on. Plus, it looks like (but don't take my word for it, I'm just coming back right now to finish windows support), the only windows-unfriendly module is the keySource module. I don't remember having problems with the other ones. I wrote a patch that, if the URL wasn't parsed successfully, tries to convert it into a EDIT : It looks like this patch passes tests, If you want to ,I can create a new PR. |
I think this can be done without any manual parsing by using the existing parsing of Pseudocode: pub(crate) enum PathOrUrl {
Path(PathBuf),
Url(Url),
}
impl From<&str> for PathOrUrl {
fn from_str(s: &str) -> Result<Self> {
// first try PathBuf::from_str(s)
// if it works return PathOrUrl::Path(path)
// if it doesn't work try Url::from_str(s) and return PathOrUrl::Url(url)
}
}
impl PathOrUrl {
pub(crate) fn as_url() -> Url {
// TODO - return a Url
}
} This type could be used in the StructOpt arguments where we currently use |
Are they? I would expect an error with:
I thought that we are currently required to do
|
How about a |
Yes, that could work. I guess we would error if the user provided both |
I think that this will return an error, only valid URLs are supported here, and it doesn't have to do w/ windows compatibility. What's causing problems is the I can think of 2 solutions to tackle this problem:
|
Maybe we should detect the absence of a URL scheme in tuftool arguments such as
--targets-url
. Currently we require afile://
URL for a local directory, but maybe we could make it more convenience and detect when a filepath lacks a protocol scheme, thus treating it as a path?Unfortunately this would probably require renaming such arguments, otherwise
--targets-url
could take a path, which might be surprising.This is related to #347, where requiring Windows users to convert
C:\my\path
tofile:///C/my/path
could be inconvenient.Open for discussion...
The text was updated successfully, but these errors were encountered: