From bf03c3559ba707e40c3862a8f43185b3a9cd5c08 Mon Sep 17 00:00:00 2001 From: Muhammad Nauman Raza Date: Tue, 29 Oct 2024 18:35:54 +0000 Subject: [PATCH] feat: option to hide the username@hostname combination --- src/main.rs | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/main.rs b/src/main.rs index 3fceb70..90410c8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -20,6 +20,10 @@ struct Args { #[arg(short = 'k', long)] kernel: bool, + /// Hide the username and hostname + #[arg(short = 'u', long)] + hide_combined: bool, + /// Hide terminal colours #[arg(short = 'z', long, default_value_t = false)] hide_colours: bool, @@ -41,16 +45,22 @@ fn display_kernel(args: &Args) { } } +// Hide the username@hostname text +fn hide_combined(args: &Args) { + if !args.hide_combined { + let hostname = fallible::hostname().unwrap_or(String::from("N/A")); + let user = username(); + let combined = format!("{}@{}", user, hostname); + println!("{: <13}{}", "", combined.bold()); + } +} + fn main() { let args = Args::parse(); let bottom = format!("c({})({})", "\"".red(), "\"".red()).to_string(); let ascii = ["(\\ /)", "( . .)", &bottom]; - let hostname = fallible::hostname().unwrap_or(String::from("N/A")); - let user = username(); - - let combined = format!("{}@{}", user, hostname); let pretty = distro(); @@ -81,7 +91,7 @@ fn main() { println!(); if !args.ascii_only { - println!("{: <13}{}", "", combined.bold()); + hide_combined(&args); cpu_arch(&args); display_kernel(&args); println!("{:>8} {:>6} {}", ascii[0], "OS".red().bold(), pretty);