Added more code comments, and fixed a potential bug in linux system name detection

This commit is contained in:
River 2023-03-01 19:24:29 -05:00
parent cc90327ced
commit 207341cbd7
4 changed files with 15 additions and 4 deletions

2
Cargo.lock generated
View File

@ -333,7 +333,7 @@ checksum = "6f61fba1741ea2b3d6a1e3178721804bb716a68a6aeba1149b5d52e3d464ea66"
[[package]] [[package]]
name = "oxidefetch" name = "oxidefetch"
version = "1.1.0" version = "1.1.1"
dependencies = [ dependencies = [
"byte-unit", "byte-unit",
"chrono", "chrono",

View File

@ -1,6 +1,6 @@
[package] [package]
name = "oxidefetch" name = "oxidefetch"
version = "1.1.0" version = "1.1.1"
edition = "2021" edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View File

@ -1,4 +1,4 @@
# oxidefetch 1.1.0 # oxidefetch 1.1.1
Fully cross platform Neofetch clone written in Rust. Up to 25 times faster than Neofetch! 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") ![alt text](image.png "Example output of OxideFetch on a WSL2 Arch Linux host")
@ -61,3 +61,4 @@ regarding your real name, IP, location, etc. You can look at the file it generat
1.0.0: Official full stable release 1.0.0: Official full stable release
1.0.1: Fixed distro name for Debian GNU/Linux. Logo & color works now. 1.0.1: Fixed distro name for Debian GNU/Linux. Logo & color works now.
1.1.0: Refactored some poorly written typing, and added support for memory. 1.1.0: Refactored some poorly written typing, and added support for memory.
1.1.1: Made sure that linux system detection won't fail if Linux has a capital L.

View File

@ -46,6 +46,11 @@ fn color_print(field_title: &str, icon: char, field: &Option<String>, color: &st
// If the field is missing, it won't print. // If the field is missing, it won't print.
if field.is_some() { if field.is_some() {
//print!("{} ", field_title.bright_white()); //print!("{} ", field_title.bright_white());
// ^^^ UNCOMMENT THIS LINE TO ENABLE FIELD TITLES!
// Comment it out to disable them.
// TODO: Add configurability to enable or disable this without recompiling.
// AT LEAST make it a crate feature so people can change the setting without
// editing the source code.
println!( println!(
"{}", "{}",
format!("{} {}", icon, field.as_ref().unwrap()).color(color) format!("{} {}", icon, field.as_ref().unwrap()).color(color)
@ -55,6 +60,10 @@ fn color_print(field_title: &str, icon: char, field: &Option<String>, color: &st
#[derive(Debug)] #[derive(Debug)]
struct InformationStruct { struct InformationStruct {
// Only fields whose setters can fail, are given Option<String> types.
// Unsure if I should coerce these fields into an Option<String> *here*, or
// within the args of color_print, since that function only accepts args of
// type Option<String>.
username: String, username: String,
hostname: String, hostname: String,
os_name: Option<String>, os_name: Option<String>,
@ -190,6 +199,7 @@ impl InformationStruct {
if sys if sys
.name() .name()
.unwrap_or(String::from("Unknown System")) .unwrap_or(String::from("Unknown System"))
.to_ascii_lowercase()
.contains("linux") { .contains("linux") {
// If we don't know what it is exactly, but we know it's Linux, // If we don't know what it is exactly, but we know it's Linux,
// just toss in good ol' Tux. // just toss in good ol' Tux.