Skip to content
Extraits de code Groupes Projets
Vérifiée Valider 6508966a rédigé par Kubat's avatar Kubat
Parcourir les fichiers

MISC: Don't need to build an 'open' bin, just need the library functionalities

parent 339a792c
Aucune branche associée trouvée
Aucune étiquette associée trouvée
1 requête de fusion!197Draft: Refactor the whole code.
...@@ -6,12 +6,6 @@ authors.workspace = true ...@@ -6,12 +6,6 @@ authors.workspace = true
license.workspace = true license.workspace = true
description = "Utilities in common for all the crates in the workspace" description = "Utilities in common for all the crates in the workspace"
[[bin]]
test = false
doc = false
name = "open"
path = "src/open/main.rs"
[lib] [lib]
doctest = false doctest = false
......
use lektor_utils::open;
use std::env;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut args = env::args();
let path_or_url = match args.nth(1) {
Some(arg) => arg,
None => return Err("usage: open <path-or-url> [--with|-w program]".into()),
};
match args.next() {
Some(arg) if arg == "--with" || arg == "-w" => {
let program = args
.next()
.ok_or("--with must be followed by the program to use for opening")?;
open::with(&path_or_url, program)
}
Some(arg) => return Err(format!("Argument '{arg}' is invalid").into()),
None => open::that(&path_or_url),
}?;
println!("Opened '{}' successfully.", path_or_url);
Ok(())
}
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter