shut up clippy

axtloss/rework-partitioning
amy 3 years ago
parent b3d6ec3143
commit dc24999a6e

@ -1,5 +1,7 @@
[package]
name = "jade"
description = "The new installer for crystal linux, contains backend and TUI"
authors = ["Amy <axtlos@tar.black>"]
version = "0.1.0"
edition = "2021"

@ -83,11 +83,11 @@ fn part_nvme(device: &str, efi: bool) {
if efi {
returncode_eval(exec(
"mkfs.vfat",
vec![String::from(format!("{}p1", device))],
vec![format!("{}p1", device)],
));
returncode_eval(exec(
"mkfs.btrfs",
vec![String::from(format!("{}p2", device))],
vec![format!("{}p2", device)],
));
mount(format!("{}p2", device), "/mnt", "");
returncode_eval(exec_workdir(
@ -118,11 +118,11 @@ fn part_nvme(device: &str, efi: bool) {
} else {
returncode_eval(exec(
"mkfs.ext4",
vec![String::from(format!("{}p1", device))],
vec![format!("{}p1", device)],
));
returncode_eval(exec(
"mkfs.btrfs",
vec![String::from(format!("{}p2", device))],
vec![format!("{}p2", device)],
));
mount(format!("{}p2", device), "/mnt/", "");
returncode_eval(exec_workdir(
@ -156,11 +156,11 @@ fn part_disk(device: &str, efi: bool) {
if efi {
returncode_eval(exec(
"mkfs.vfat",
vec![String::from(format!("{}1", device))],
vec![format!("{}1", device)],
));
returncode_eval(exec(
"mkfs.btrfs",
vec![String::from(format!("{}2", device))],
vec![format!("{}2", device)],
));
mount(format!("{}2", device), "/mnt", "");
returncode_eval(exec_workdir(
@ -191,11 +191,11 @@ fn part_disk(device: &str, efi: bool) {
} else {
returncode_eval(exec(
"mkfs.ext4",
vec![String::from(format!("{}1", device))],
vec![format!("{}1", device)],
));
returncode_eval(exec(
"mkfs.btrfs",
vec![String::from(format!("{}2", device))],
vec![format!("{}2", device)],
));
mount(format!("{}2", device), "/mnt/", "");
returncode_eval(exec_workdir(
@ -230,7 +230,7 @@ fn mount(partition: String, mountpoint: &str, options: &str) {
returncode_eval(exec(
"mount",
vec![
String::from(partition),
partition,
String::from(mountpoint),
String::from("-o"),
String::from(options),

@ -46,7 +46,7 @@ pub fn new_user(username: &str, hasroot: bool, password: &str) {
vec![
String::from("--password"),
String::from("$(echo"),
String::from(format!("${}", password)),
format!("${}", password),
String::from("|"),
String::from("openssl"),
String::from("passwd"),
@ -75,7 +75,7 @@ pub fn root_pass(root_pass: &str) {
vec![
String::from("--password"),
String::from("$(echo"),
String::from(format!("${{{}}}", root_pass)),
format!("${{{}}}", root_pass),
String::from("|"),
String::from("openssl"),
String::from("passwd"),

@ -17,22 +17,10 @@ pub fn create_file(path: &str) {
pub fn append_file(path: &str, content: &str) -> std::io::Result<()> {
log(format!("Appending {} to file {}", content, path));
let mut file = OpenOptions::new().append(true).open(path)?;
file.write(content.as_bytes())?;
file.write_all(content.as_bytes())?;
Ok(())
}
pub fn delete_file(path: &str) {
let return_val = std::fs::remove_file(path);
match return_val {
Ok(_) => {
log(format!("Deleted file {}", path));
}
Err(e) => {
crash(format!("Failed to delete file {}, Error: {}", path, e), 1);
}
}
}
pub fn create_directory(path: &str) {
let return_val = std::fs::create_dir(path);
match return_val {
@ -48,19 +36,3 @@ pub fn create_directory(path: &str) {
}
}
pub fn overwrite_file(path: &str, content: &str) {
delete_file(path);
create_file(path);
let return_val = append_file(path, content);
match return_val {
Ok(_) => {
log(format!("Overwrote file {}", path));
}
Err(e) => {
crash(
format!("Failed to overwrite file {}, Error: {}", path, e),
1,
);
}
}
}

@ -7,10 +7,6 @@ pub fn install(pkgs: Vec<&str>) {
install::install(pkgs);
}
pub fn info(a: String) {
strings::info(a);
}
pub fn crash(a: String, b: i32) {
strings::crash(a, b);
}

@ -3,14 +3,7 @@ use std::env;
use std::process::exit;
use std::str::FromStr;
use std::time::UNIX_EPOCH;
pub fn info(a: String) {
let a = if env::var("JADE_UWU").unwrap_or_else(|_| "".to_string()) == "true" {
uwu!(&a)
} else {
a
};
println!("\x1b[2;22;35m❖\x1b[0m \x1b[1;37m{}\x1b[0m", a)
}
pub fn crash(a: String, b: i32) {
let a = if env::var("JADE_UWU").unwrap_or_else(|_| "".to_string()) == "true" {
uwu!(&a)

Loading…
Cancel
Save