Small changes
This commit is contained in:
parent
922098337f
commit
bbddf08b84
@ -9,7 +9,7 @@ use config::Config;
|
||||
use std::io;
|
||||
use std::path::PathBuf;
|
||||
|
||||
fn input() -> Result<String, io::Error> {
|
||||
fn input() -> io::Result<String> {
|
||||
let mut val = String::new();
|
||||
io::stdin().read_line(&mut val)?;
|
||||
Ok(val)
|
||||
@ -52,7 +52,7 @@ fn main() {
|
||||
if input().unwrap().trim().to_lowercase() == "y" {
|
||||
prog.set_default().unwrap_or_else(|err| {
|
||||
println!(
|
||||
"An error occursed trying to set default {:?}",
|
||||
"An error occurred trying to set default {:?}",
|
||||
err.kind()
|
||||
)
|
||||
});
|
||||
|
@ -88,19 +88,19 @@ impl<'a> PackageManager<'a> {
|
||||
}
|
||||
// Allows setting the default in rux.conf
|
||||
pub fn set_default(&self) -> std::io::Result<()> {
|
||||
let mut home = match env::home_dir() {
|
||||
let mut conf = match env::home_dir() {
|
||||
Some(path) => path,
|
||||
None => {
|
||||
println!("Could not find home! Default cannot set properly!");
|
||||
std::process::exit(1)
|
||||
}
|
||||
};
|
||||
home.push(".config/rux/");
|
||||
fs::create_dir_all(&home).unwrap_or_else(|why| {
|
||||
conf.push(".config/rux/");
|
||||
fs::create_dir_all(&conf).unwrap_or_else(|why| {
|
||||
println!("! {:?}", why.kind());
|
||||
});
|
||||
home.push("rux.conf");
|
||||
let mut file = File::create(home)?;
|
||||
conf.push("rux.conf");
|
||||
let mut file = File::create(conf)?;
|
||||
file.write_all(self.name.as_bytes())?;
|
||||
Ok(())
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user