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]]
name = "oxidefetch"
version = "1.1.0"
version = "1.1.1"
dependencies = [
"byte-unit",
"chrono",

View File

@ -1,6 +1,6 @@
[package]
name = "oxidefetch"
version = "1.1.0"
version = "1.1.1"
edition = "2021"
# 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!
![alt text](image.png "Example output of OxideFetch on a WSL2 Arch Linux host")
@ -60,4 +60,5 @@ regarding your real name, IP, location, etc. You can look at the file it generat
### Changelog
1.0.0: Official full stable release
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 field.is_some() {
//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!(
"{}",
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)]
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,
hostname: String,
os_name: Option<String>,
@ -190,6 +199,7 @@ impl InformationStruct {
if sys
.name()
.unwrap_or(String::from("Unknown System"))
.to_ascii_lowercase()
.contains("linux") {
// If we don't know what it is exactly, but we know it's Linux,
// just toss in good ol' Tux.