mirror of
https://github.com/NotAShelf/microfetch.git
synced 2026-06-24 04:43:25 +00:00
Compare commits
No commits in common. "928452faba58a261f78e32c5e549dfe5ad8caf16" and "bf1b319971756cdd408bdbb311ef9e31f42bd2df" have entirely different histories.
928452faba
...
bf1b319971
2 changed files with 15 additions and 6 deletions
|
|
@ -2,7 +2,7 @@ condense_wildcard_suffixes = true
|
|||
doc_comment_code_block_width = 80
|
||||
edition = "2024" # Keep in sync with Cargo.toml.
|
||||
enum_discrim_align_threshold = 60
|
||||
force_explicit_abi = true
|
||||
force_explicit_abi = false
|
||||
force_multiline_blocks = true
|
||||
format_code_in_doc_comments = true
|
||||
format_macro_matchers = true
|
||||
|
|
|
|||
19
src/main.rs
19
src/main.rs
|
|
@ -1,11 +1,18 @@
|
|||
mod colors;
|
||||
mod desktop;
|
||||
mod release;
|
||||
mod syscall;
|
||||
mod system;
|
||||
mod uptime;
|
||||
|
||||
use std::io::{self, Cursor, Write};
|
||||
|
||||
use microfetch_lib::{
|
||||
UtsName,
|
||||
colors::{COLORS, print_dots},
|
||||
pub use microfetch_lib::UtsName;
|
||||
|
||||
use crate::{
|
||||
colors::print_dots,
|
||||
desktop::get_desktop_info,
|
||||
release::{get_os_pretty_name, get_system_info},
|
||||
syscall::sys_write,
|
||||
system::{
|
||||
get_memory_usage,
|
||||
get_root_disk_usage,
|
||||
|
|
@ -57,6 +64,8 @@ struct Fields {
|
|||
fn print_system_info(
|
||||
fields: &Fields,
|
||||
) -> Result<(), Box<dyn std::error::Error>> {
|
||||
use crate::colors::COLORS;
|
||||
|
||||
let Fields {
|
||||
user_info,
|
||||
os_name,
|
||||
|
|
@ -93,7 +102,7 @@ fn print_system_info(
|
|||
let len =
|
||||
usize::try_from(cursor.position()).expect("cursor position fits usize");
|
||||
// Direct syscall to avoid stdout buffering allocation
|
||||
let written = unsafe { sys_write(1, buf.as_ptr(), len) };
|
||||
let written = unsafe { syscall::sys_write(1, buf.as_ptr(), len) };
|
||||
if written < 0 {
|
||||
return Err(io::Error::last_os_error().into());
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue