added exit codes
This commit is contained in:
parent
bbb73290ef
commit
85b463b9b8
1 changed files with 7 additions and 7 deletions
14
src/main.rs
14
src/main.rs
|
@ -1,7 +1,7 @@
|
||||||
use std::{
|
use std::{
|
||||||
env::{args, current_dir},
|
env::{args, current_dir},
|
||||||
path::Path,
|
path::Path,
|
||||||
process::{Command, Stdio}
|
process::{Command, exit, Stdio}
|
||||||
};
|
};
|
||||||
|
|
||||||
mod config;
|
mod config;
|
||||||
|
@ -20,8 +20,8 @@ fn main() {
|
||||||
let i_target = arg_target.unwrap_or(&default);
|
let i_target = arg_target.unwrap_or(&default);
|
||||||
let target = Path::new(i_target);
|
let target = Path::new(i_target);
|
||||||
if !target.exists() {
|
if !target.exists() {
|
||||||
println!("\"{}\" does not exist.", i_target);
|
println!("open: \"{}\" does not exist.", i_target);
|
||||||
return;
|
exit(1);
|
||||||
}
|
}
|
||||||
let i_ext = target.extension();
|
let i_ext = target.extension();
|
||||||
let i_filename: String;
|
let i_filename: String;
|
||||||
|
@ -43,11 +43,11 @@ fn main() {
|
||||||
let i_exe = config.get(ext, "command");
|
let i_exe = config.get(ext, "command");
|
||||||
if i_exe.is_none() {
|
if i_exe.is_none() {
|
||||||
match ext {
|
match ext {
|
||||||
"open" => {},
|
"open" => println!("open: no zero-parameter command specified."),
|
||||||
"dir" => println!("No command specified for directories."),
|
"dir" => println!("open: no command specified for directories."),
|
||||||
_ => println!("No command specified for \"{}\" files.", ext)
|
_ => println!("open: no command specified for \"{}\" files.", ext)
|
||||||
}
|
}
|
||||||
return;
|
exit(1);
|
||||||
}
|
}
|
||||||
let exe = i_exe.unwrap();
|
let exe = i_exe.unwrap();
|
||||||
let mut parts = exe.split(" ");
|
let mut parts = exe.split(" ");
|
||||||
|
|
Loading…
Reference in a new issue