diff --git a/Cargo.lock b/Cargo.lock index cd0ac11..a906dc1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -333,7 +333,7 @@ checksum = "6f61fba1741ea2b3d6a1e3178721804bb716a68a6aeba1149b5d52e3d464ea66" [[package]] name = "oxidefetch" -version = "1.4.5" +version = "1.4.6" dependencies = [ "byte-unit", "chrono", diff --git a/Cargo.toml b/Cargo.toml index 27c4d34..7fdb37f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "oxidefetch" description = "A fast, cross platform Fetch program for your terminal" -version = "1.4.5" +version = "1.4.6" edition = "2021" authors = [ "NamedNeon", "shibedrill" ] license = "MIT" diff --git a/README.md b/README.md index 59c9000..b84ab8d 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# oxidefetch 1.4.5 +# oxidefetch 1.4.6 Fully cross platform Neofetch clone written in Rust. Up to 25 times faster than Neofetch! ![alt text](image.png "Example output of OxideFetch on a WSL2 Arch Linux host") @@ -97,6 +97,7 @@ No weird quirks to report at this time. **1.4.3:** Removed newline print before information. This should be up to the user to print, using their shell profile. **1.4.4:** Fixed an issue where GPUs would all print on one line. **1.4.5:** Minor changes to system color detection. Removed all warnings. +**1.4.6:** Cargo formatting applied to all files. Mild string reformatting in print statements. ### License This software is covered by the MIT license. See license.txt for details. diff --git a/src/main.rs b/src/main.rs index da28ef8..fa77d2f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,28 +2,29 @@ Copyright 2023 shibedrill & Namedneon -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the “Software”), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -of the Software, and to permit persons to whom the Software is furnished to do +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the “Software”), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in all +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ mod terminal; +use crate::terminal::get_terminal; use byte_unit::*; use chrono::*; use colored::*; @@ -31,7 +32,6 @@ use compound_duration; use std::env; use sysinfo::*; use whoami; -use crate::terminal::get_terminal; fn main() { // Generate system info struct @@ -184,23 +184,19 @@ impl Information { // TODO: Please fix this horrible logic. It needs refactoring. match command_output { Err(_) => None, - Ok(output_bytes) => { - match String::from_utf8(output_bytes.stdout) { - Err(_) => None, - Ok(output_string) => { - match output_string.as_ref() { - "" => None, - _ => { - let mut gpu_vec = vec!(); - for s in output_string.trim().split('\n') { - gpu_vec.push(s.to_string()); - } - Some(gpu_vec) - } + Ok(output_bytes) => match String::from_utf8(output_bytes.stdout) { + Err(_) => None, + Ok(output_string) => match output_string.as_ref() { + "" => None, + _ => { + let mut gpu_vec = vec![]; + for s in output_string.trim().split('\n') { + gpu_vec.push(s.to_string()); } + Some(gpu_vec) } - } - } + }, + }, } } } @@ -257,7 +253,8 @@ impl Information { } }, - color: String::from(match sys + color: String::from( + match sys .name() .unwrap_or(String::from("Unknown System")) .as_ref() @@ -275,7 +272,8 @@ impl Information { "AlmaLinux" => "yellow", _ => "bright white", - }), + }, + ), } } } @@ -294,9 +292,20 @@ mod test { let result = fs::write("./test_output.txt", data_string); if result.is_ok() { - println!("\nHEY THERE! A logging file was generated by this test. \nIt's located in this folder, and called 'test_output.txt'. \nSEND THIS FILE to the maintainer of the project!\n"); + println!( + " +HEY THERE! A logging file was generated by this test. \ +It's located in this folder, and called 'test_output.txt'. \ +SEND THIS FILE to the maintainer of the project! + " + ); } else { - println!("Woops. A file wasn't able to be generated. The program or user might not have permission to make files in this directory."); + println!( + " +Woops. A file wasn't able to be generated. \ +The program or user might not have permission to make files in this directory. + " + ); }; assert!(result.is_ok()); diff --git a/src/terminal.rs b/src/terminal.rs index 4007168..6fad81f 100644 --- a/src/terminal.rs +++ b/src/terminal.rs @@ -2,29 +2,29 @@ Copyright 2023 shibedrill & Namedneon -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the “Software”), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -of the Software, and to permit persons to whom the Software is furnished to do +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the “Software”), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in all +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -use std::env; -use std::collections::HashMap; use lazy_static::lazy_static; +use std::collections::HashMap; +use std::env; use sysinfo::{Pid, PidExt, ProcessExt, System, SystemExt}; lazy_static! { @@ -43,10 +43,7 @@ lazy_static! { } // Allows detection of shells that host themselves (i.e. Command Prompt). -const SELF_HOSTED_SHELLS: [&str; 2] = [ - "cmd.exe", - "powershell.exe" -]; +const SELF_HOSTED_SHELLS: [&str; 2] = ["cmd.exe", "powershell.exe"]; macro_rules! match_env_to_terminal { ($env: expr, $name: expr) => { @@ -54,7 +51,7 @@ macro_rules! match_env_to_terminal { Ok(_) => return Some($name.to_string()), Err(_) => (), }; - } + }; } pub fn get_terminal() -> Option { @@ -93,9 +90,11 @@ pub fn get_terminal() -> Option { 'find_shell: loop { let ppid = pid_to_ppid(pid); - if ppid.is_none() { // We ran out of parents. + if ppid.is_none() { + // We ran out of parents. return None; - } else if ppid.unwrap().as_u32() == 1 { // We have reached the daemon. + } else if ppid.unwrap().as_u32() == 1 { + // We have reached the daemon. return None; } @@ -131,7 +130,7 @@ pub fn get_terminal() -> Option { Some(f) => { // Try to get name. name = pid_to_name(f); - }, + } }; } @@ -146,9 +145,9 @@ pub fn get_terminal() -> Option { } Some(res) - }, + } None => None, - } + }; } fn pid_to_name(pid: Pid) -> Option { @@ -184,4 +183,4 @@ fn pid_to_ppid(pid: Pid) -> Option { } None -} \ No newline at end of file +}