formatting stuff

This commit is contained in:
shibedrill 2023-11-11 14:35:46 -05:00
parent 1d030ca840
commit 8b7cade4e4
5 changed files with 69 additions and 60 deletions

2
Cargo.lock generated
View File

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

View File

@ -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"

View File

@ -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.

View File

@ -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());

View File

@ -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<String> {
@ -93,9 +90,11 @@ pub fn get_terminal() -> Option<String> {
'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<String> {
Some(f) => {
// Try to get name.
name = pid_to_name(f);
},
}
};
}
@ -146,9 +145,9 @@ pub fn get_terminal() -> Option<String> {
}
Some(res)
},
}
None => None,
}
};
}
fn pid_to_name(pid: Pid) -> Option<String> {
@ -184,4 +183,4 @@ fn pid_to_ppid(pid: Pid) -> Option<Pid> {
}
None
}
}