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