diff --git a/src/functions/partition.rs b/src/functions/partition.rs index 707df24..8a9a8c8 100755 --- a/src/functions/partition.rs +++ b/src/functions/partition.rs @@ -7,7 +7,7 @@ pub fn partition(device: &str, mode: &str, efi: bool) { } else { log(format!("automatically partitioning {}", device)); if efi { - let return_code = exec( + returncode_eval(exec( "parted", vec![ String::from("-s"), @@ -15,16 +15,8 @@ pub fn partition(device: &str, mode: &str, efi: bool) { String::from("mklabel"), String::from("gpt"), ], - ); - match return_code { - Ok(_) => { - log("Created GPT label".to_string()); - } - Err(e) => { - crash(format!("Failed to create GPT label, Error: {}", e), 1); - } - } - let return_code = exec( + )); + returncode_eval(exec( "parted", vec![ String::from("-s"), @@ -34,19 +26,8 @@ pub fn partition(device: &str, mode: &str, efi: bool) { String::from("0"), String::from("300"), ], - ); - match return_code { - Ok(_) => { - log("Created fat32 EFI partition".to_string()); - } - Err(e) => { - crash( - format!("Failed to create fat32 EFI partition, Error: {}", e), - 1, - ); - } - } - let return_code = exec( + )); + returncode_eval(exec( "parted", vec![ String::from("-s"), @@ -56,20 +37,9 @@ pub fn partition(device: &str, mode: &str, efi: bool) { String::from("300"), String::from("100%"), ], - ); - match return_code { - Ok(_) => { - log("Created btrfs root partition".to_string()); - } - Err(e) => { - crash( - format!("Failed to create btrfs root partition, Error: {}", e), - 1, - ); - } - } + )); } else { - let return_code = exec( + returncode_eval(exec( "parted", vec![ String::from("-s"), @@ -77,16 +47,8 @@ pub fn partition(device: &str, mode: &str, efi: bool) { String::from("mklabel"), String::from("msdos"), ], - ); - match return_code { - Ok(_) => { - log("Created MSDOS label".to_string()); - } - Err(e) => { - crash(format!("Failed to create MSDOS label, Error: {}", e), 1); - } - } - let return_code = exec( + )); + returncode_eval(exec( "parted", vec![ String::from("-s"), @@ -96,19 +58,8 @@ pub fn partition(device: &str, mode: &str, efi: bool) { String::from("512MIB"), String::from("100&"), ], - ); - match return_code { - Ok(_) => { - log("Created btrfs root partition".to_string()); - } - Err(e) => { - crash( - format!("Failed to create btrfs root partition, Error: {}", e), - 1, - ); - } - } - let return_code = exec( + )); + returncode_eval(exec( "parted", vec![ String::from("-s"), @@ -118,18 +69,7 @@ pub fn partition(device: &str, mode: &str, efi: bool) { String::from("1MIB"), String::from("512MIB"), ], - ); - match return_code { - Ok(_) => { - log("Created ext4 boot partition".to_string()); - } - Err(e) => { - crash( - format!("Failed to create ext4 boot partition, Error: {}", e), - 1, - ); - } - } + )); } } if device.contains("nvme") {