Update main.rs

This commit is contained in:
Voyage 2023-06-19 22:28:31 +03:00 committed by GitHub
parent aef1690c1b
commit 90fd10f202
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -59,7 +59,7 @@ fn main() {
// I know it's terrible, but it works.
let mut kernel = String::new();
{
let kernel_file = File::open("/proc/version").expect("do u even linux bro???");
let kernel_file = File::open("/proc/version").expect("Read the README.md you dumbass");
let mut kernel_reader = BufReader::new(kernel_file);
kernel_reader.read_line(&mut kernel).expect("Failed string conversion");
}
@ -135,9 +135,19 @@ fn main() {
}
// Get shell
let shell = env::var("SHELL").expect("Could not read $SHELL variable");
println!("│ Shell: {}", Cyan.paint(shell));
let shell_raw = env::var("SHELL").expect("Could not read $SHELL variable");
// Split the path using '/' as the separator
// Thanks ChatGPT
let parts: Vec<&str> = shell_raw.rsplitn(2, '/').collect();
// Check if the path contains at least one '/'
if parts.len() > 1 {
let shell = parts[0];
println!("│ Shell: {}", Cyan.paint(shell));
} else {
println!("Invalid path format.");
}
// Time for a challenge, Get CPU model!
{
let file = File::open("/proc/cpuinfo").expect("Could not read /proc/cpuinfo");