Better formatting
This commit is contained in:
parent
9542d122b5
commit
a92f51e20a
@ -42,36 +42,32 @@ impl Config {
|
||||
match (prog.first(), &self.term) {
|
||||
(None, &None) => {
|
||||
let mut child = Command::new(&command).spawn().expect(
|
||||
"Failed to open package manager"
|
||||
"Failed to open package manager",
|
||||
);
|
||||
child.wait().expect("Failed to wait on package manager");
|
||||
},
|
||||
}
|
||||
(None, &Some(ref term)) => {
|
||||
let mut child = Command::new(&command)
|
||||
.arg(term)
|
||||
.spawn()
|
||||
.expect("Failed to open package manager");
|
||||
let mut child = Command::new(&command).arg(term).spawn().expect(
|
||||
"Failed to open package manager",
|
||||
);
|
||||
child.wait().expect("Failed to wait on package manager");
|
||||
},
|
||||
}
|
||||
(Some(_), &None) => {
|
||||
for arg in &prog {
|
||||
let mut child =Command::new(&command)
|
||||
.arg(arg)
|
||||
.spawn()
|
||||
.expect("Failed to open package manager");
|
||||
let mut child = Command::new(&command).arg(arg).spawn().expect(
|
||||
"Failed to open package manager",
|
||||
);
|
||||
child.wait().expect("Failed to wait on child");
|
||||
}
|
||||
},
|
||||
}
|
||||
(Some(_), &Some(ref term)) => {
|
||||
for arg in &prog {
|
||||
let mut child = Command::new(&command)
|
||||
.arg(arg)
|
||||
.arg(term)
|
||||
.spawn()
|
||||
.expect("Failed to open package manager");
|
||||
let mut child = Command::new(&command).arg(arg).arg(term).spawn().expect(
|
||||
"Failed to open package manager",
|
||||
);
|
||||
child.wait().expect("Failed to wait on child");
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
/// Creates a `Config` from passed arguments, parses the `Management` enum
|
||||
|
11
src/main.rs
11
src/main.rs
@ -23,9 +23,7 @@ fn main() {
|
||||
let config = Config::new();
|
||||
|
||||
//Sets a path to `~/.config/rux/`
|
||||
let mut ruxconf = std::env::home_dir().unwrap_or_else(|| {
|
||||
PathBuf::new()
|
||||
});
|
||||
let mut ruxconf = std::env::home_dir().unwrap_or_else(|| PathBuf::new());
|
||||
ruxconf.push(".config/rux/rux.conf");
|
||||
|
||||
// Checks if `~/.config/rux/rux.conf` exists and skips loading any
|
||||
@ -34,7 +32,7 @@ fn main() {
|
||||
let pac = read_default(ruxconf).unwrap_or_else(|err| {
|
||||
eprintln!("{:?}", err);
|
||||
std::process::exit(1)
|
||||
});
|
||||
});
|
||||
config.run(pac);
|
||||
std::process::exit(0);
|
||||
}
|
||||
@ -63,10 +61,7 @@ fn main() {
|
||||
println!("Would you like to set {} as default? [y/N]", prog.name);
|
||||
if input().unwrap().trim().to_lowercase() == "y" {
|
||||
prog.set_default().unwrap_or_else(|err| {
|
||||
println!(
|
||||
"An error occurred trying to set default {:?}",
|
||||
err.kind()
|
||||
)
|
||||
println!("An error occurred trying to set default {:?}", err.kind())
|
||||
});
|
||||
}
|
||||
config.run(prog);
|
||||
|
@ -12,7 +12,7 @@ pub struct PackageManager<'a> {
|
||||
pub name: &'a str,
|
||||
pub search: Option<Vec<&'a str>>,
|
||||
pub install: Option<Vec<&'a str>>,
|
||||
pub uninstall: Option<Vec<&'a str>>,
|
||||
pub uninstall: Option<Vec<&'a str>>,
|
||||
pub sup: Option<Vec<&'a str>>,
|
||||
pub purge: Option<Vec<&'a str>>,
|
||||
pub update: Option<Vec<&'a str>>,
|
||||
@ -60,7 +60,7 @@ impl<'a> PackageManager<'a> {
|
||||
name: "apt",
|
||||
search: Some(vec!["apt", "search"]),
|
||||
install: Some(vec!["apt", "install"]),
|
||||
uninstall:Some(vec!["apt", "remove"]),
|
||||
uninstall: Some(vec!["apt", "remove"]),
|
||||
sup: Some(vec!["apt", "update", "upgrade"]),
|
||||
purge: Some(vec!["apt", "purge"]),
|
||||
upgrade: Some(vec!["apt", "upgrade"]),
|
||||
@ -97,7 +97,7 @@ impl<'a> PackageManager<'a> {
|
||||
let conf = conf.join(".config").join("rux");
|
||||
fs::create_dir_all(&conf).unwrap_or_else(|err| {
|
||||
println!("Error setting default: {}", err);
|
||||
return ()
|
||||
return ();
|
||||
});
|
||||
let conf = conf.join("rux.conf");
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user