Support URL arguments
This commit is contained in:
parent
1467351211
commit
d322017e09
2 changed files with 14 additions and 3 deletions
|
|
@ -3,7 +3,7 @@
|
||||||
Name=COSMIC Files
|
Name=COSMIC Files
|
||||||
Name[pl]=Pliki COSMIC
|
Name[pl]=Pliki COSMIC
|
||||||
Name[pt-BR]=Arquivos do COSMIC
|
Name[pt-BR]=Arquivos do COSMIC
|
||||||
Exec=cosmic-files %F
|
Exec=cosmic-files %U
|
||||||
Terminal=false
|
Terminal=false
|
||||||
Type=Application
|
Type=Application
|
||||||
StartupNotify=true
|
StartupNotify=true
|
||||||
|
|
|
||||||
15
src/lib.rs
15
src/lib.rs
|
|
@ -98,10 +98,21 @@ pub fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
} else if &arg == "--trash" {
|
} else if &arg == "--trash" {
|
||||||
Location::Trash
|
Location::Trash
|
||||||
} else {
|
} else {
|
||||||
match fs::canonicalize(&arg) {
|
//TODO: support more URLs
|
||||||
|
let path = match url::Url::parse(&arg) {
|
||||||
|
Ok(url) => match url.to_file_path() {
|
||||||
|
Ok(path) => path,
|
||||||
|
Err(()) => {
|
||||||
|
log::warn!("invalid argument {:?}", arg);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Err(_) => PathBuf::from(arg),
|
||||||
|
};
|
||||||
|
match fs::canonicalize(&path) {
|
||||||
Ok(absolute) => Location::Path(absolute),
|
Ok(absolute) => Location::Path(absolute),
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
log::warn!("failed to canonicalize {:?}: {}", arg, err);
|
log::warn!("failed to canonicalize {:?}: {}", path, err);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue