From 27f0f461f183b9f7d7af2fe16e0642f188663ef9 Mon Sep 17 00:00:00 2001 From: Yang Hau Date: Mon, 26 Aug 2024 00:56:31 +0800 Subject: [PATCH] lsmem: Add noheadings --- src/uu/lsmem/src/lsmem.rs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/uu/lsmem/src/lsmem.rs b/src/uu/lsmem/src/lsmem.rs index 89cf111..9e7449b 100644 --- a/src/uu/lsmem/src/lsmem.rs +++ b/src/uu/lsmem/src/lsmem.rs @@ -16,7 +16,11 @@ use std::str::FromStr; use uucore::{error::UResult, format_usage, help_about, help_usage}; use tabled::{ - settings::{location::ByColumnName, object, Alignment, Disable, Modify, Style}, + settings::{ + location::ByColumnName, + object::{self, Rows}, + Alignment, Disable, Modify, Style, + }, Table, Tabled, }; @@ -25,6 +29,7 @@ const USAGE: &str = help_usage!("lsmem.md"); mod options { pub const BYTES: &str = "bytes"; + pub const NOHEADINGS: &str = "noheadings"; } // const BUFSIZ: usize = 1024; @@ -209,7 +214,7 @@ struct Options { // raw: bool, // export: bool, // json: bool, - // noheadings: bool, + noheadings: bool, // summary: bool, list_all: bool, bytes: bool, @@ -253,7 +258,7 @@ impl Options { // raw: false, // export: false, // json: false, - // noheadings: false, + noheadings: false, // summary: false, list_all: false, bytes: false, @@ -475,6 +480,10 @@ fn print_table(lsmem: &Lsmem, opts: &Options) { table.with(Disable::column(ByColumnName::new("NODE"))); table.with(Disable::column(ByColumnName::new("ZONES"))); + if opts.noheadings { + table.with(Disable::row(Rows::first())); + } + println!("{table}"); } @@ -516,11 +525,11 @@ where #[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let matches: clap::ArgMatches = uu_app().try_get_matches_from(args)?; - let opt_bytes = matches.get_flag(options::BYTES); let mut lsmem = Lsmem::new(); let mut opts = Options::new(); - opts.bytes = opt_bytes; + opts.bytes = matches.get_flag(options::BYTES); + opts.noheadings = matches.get_flag(options::NOHEADINGS); read_info(&mut lsmem, &mut opts);