Skip to content

Commit 9def311

Browse files
committed
Move noheadings flag into Lsns struct
Signed-off-by: Malhar Vora <mlvora.2010@gmail.com>
1 parent d6ea37b commit 9def311

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

src/uu/lsns/src/lsns.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,25 +84,24 @@ struct Namespace {
8484
struct Lsns {
8585
processes: Vec<Process>,
8686
namespaces: Vec<Namespace>,
87+
noheadings: bool,
8788
}
8889

8990
#[uucore::main]
9091
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
9192
let matches = uu_app().try_get_matches_from(args)?;
9293

93-
// Print no headings if this flag is set
94-
let noheadings = matches.get_flag("noheadings");
95-
9694
let mut lsns = Lsns {
9795
processes: Vec::new(),
9896
namespaces: Vec::new(),
97+
noheadings: matches.get_flag("noheadings"),
9998
};
10099

101100
read_processes(PATH_PROC, &mut lsns)?;
102101

103102
read_namespaces(&mut lsns)?;
104103

105-
display_namespaces(&lsns, noheadings)?;
104+
display_namespaces(&lsns)?;
106105

107106
Ok(())
108107
}
@@ -491,7 +490,7 @@ impl NamespaceType {
491490

492491
/// Display namespaces in default format using smartcols
493492
#[cfg(target_os = "linux")]
494-
fn display_namespaces(lsns: &Lsns, noheadings: bool) -> Result<(), LsnsError> {
493+
fn display_namespaces(lsns: &Lsns) -> Result<(), LsnsError> {
495494
use smartcols_sys::{SCOLS_FL_RIGHT, SCOLS_FL_TRUNC};
496495

497496
// Initialize smartcols
@@ -501,7 +500,7 @@ fn display_namespaces(lsns: &Lsns, noheadings: bool) -> Result<(), LsnsError> {
501500
let mut table = Table::new()?;
502501

503502
// Enable or disable headings based on flag
504-
if noheadings {
503+
if lsns.noheadings {
505504
table.enable_headings(false)?;
506505
}
507506

@@ -572,7 +571,7 @@ fn display_namespaces(lsns: &Lsns, noheadings: bool) -> Result<(), LsnsError> {
572571
}
573572

574573
#[cfg(not(target_os = "linux"))]
575-
fn display_namespaces(_lsns: &Lsns, _noheadings: bool) -> Result<(), LsnsError> {
574+
fn display_namespaces(_lsns: &Lsns) -> Result<(), LsnsError> {
576575
Err(LsnsError::UnsupportedPlatform)
577576
}
578577

0 commit comments

Comments
 (0)