Skip to content

Commit ffae094

Browse files
committed
Add noheadings flag to the command
Signed-off-by: Malhar Vora <mlvora.2010@gmail.com>
1 parent 34e2b36 commit ffae094

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

src/uu/lsns/src/lsns.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ mod errors;
1010
#[cfg(target_os = "linux")]
1111
mod smartcols;
1212

13-
use clap::{Command, crate_version};
13+
use clap::{Arg, ArgAction, Command, crate_version};
1414
#[cfg(target_os = "linux")]
1515
use std::ffi::CString;
1616
#[cfg(target_os = "linux")]
@@ -88,7 +88,10 @@ struct Lsns {
8888

8989
#[uucore::main]
9090
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
91-
let _matches = uu_app().try_get_matches_from(args)?;
91+
let matches = uu_app().try_get_matches_from(args)?;
92+
93+
// Print no headings if this flag is set
94+
let noheadings = matches.get_flag("noheadings");
9295

9396
let mut lsns = Lsns {
9497
processes: Vec::new(),
@@ -110,6 +113,13 @@ pub fn uu_app() -> Command {
110113
.about(ABOUT)
111114
.override_usage(format_usage(USAGE))
112115
.infer_long_args(true)
116+
.arg(
117+
Arg::new("noheadings")
118+
.short('n')
119+
.long("noheadings")
120+
.action(ArgAction::SetTrue)
121+
.help("don't print headings"),
122+
)
113123
}
114124

115125
/// Read information of all the processes from /proc

0 commit comments

Comments
 (0)