formatting stuff
This commit is contained in:
parent
1d030ca840
commit
8b7cade4e4
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -333,7 +333,7 @@ checksum = "6f61fba1741ea2b3d6a1e3178721804bb716a68a6aeba1149b5d52e3d464ea66"
|
||||
|
||||
[[package]]
|
||||
name = "oxidefetch"
|
||||
version = "1.4.5"
|
||||
version = "1.4.6"
|
||||
dependencies = [
|
||||
"byte-unit",
|
||||
"chrono",
|
||||
|
@ -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"
|
||||
|
@ -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!
|
||||
|
||||

|
||||
@ -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.
|
||||
|
49
src/main.rs
49
src/main.rs
@ -24,6 +24,7 @@ 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());
|
||||
|
@ -22,9 +22,9 @@ 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> {
|
||||
|
Loading…
Reference in New Issue
Block a user