mirror of
https://github.com/lsd-rs/lsd
synced 2024-12-14 14:12:31 +00:00
add --no-symlink option
This commit is contained in:
parent
4767ef8c11
commit
e145697b4e
3 changed files with 39 additions and 23 deletions
|
@ -171,7 +171,7 @@ pub fn build() -> App<'static, 'static> {
|
||||||
.multiple(true)
|
.multiple(true)
|
||||||
.number_of_values(1)
|
.number_of_values(1)
|
||||||
.require_delimiter(true)
|
.require_delimiter(true)
|
||||||
.possible_values(&["permission", "user", "group", "size", "date", "name","namewithoutsymlink" ])
|
.possible_values(&["permission", "user", "group", "size", "date", "name"])
|
||||||
.default_value("permission,user,group,size,date,name")
|
.default_value("permission,user,group,size,date,name")
|
||||||
.help("Specify the blocks that will be displayed and in what order"),
|
.help("Specify the blocks that will be displayed and in what order"),
|
||||||
)
|
)
|
||||||
|
@ -180,4 +180,10 @@ pub fn build() -> App<'static, 'static> {
|
||||||
.long("classic")
|
.long("classic")
|
||||||
.help("Enable classic mode (no colors or icons)"),
|
.help("Enable classic mode (no colors or icons)"),
|
||||||
)
|
)
|
||||||
|
.arg(
|
||||||
|
Arg::with_name("no-symlink")
|
||||||
|
.long("no-symlink")
|
||||||
|
.multiple(true)
|
||||||
|
.help("Do not display symlink target"),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -296,26 +296,34 @@ fn get_long_output(
|
||||||
&flags,
|
&flags,
|
||||||
)),
|
)),
|
||||||
Block::Date => strings.push(meta.date.render(colors, padding_rules.date, &flags)),
|
Block::Date => strings.push(meta.date.render(colors, padding_rules.date, &flags)),
|
||||||
Block::Name => strings.push(meta.name.render(colors, icons, Some(padding_rules.name))),
|
Block::Name => {
|
||||||
Block::NameWithSymlink => match meta.symlink.symlink_string() {
|
if flags.no_symlink {
|
||||||
Some(_) => {
|
strings.push(meta.name.render(colors, icons, Some(padding_rules.name)));
|
||||||
strings.push(meta.name.render(colors, icons, None));
|
} else {
|
||||||
strings.push(meta.indicator.render(&flags));
|
match meta.symlink.symlink_string() {
|
||||||
strings.push(meta.symlink.render(
|
Some(_) => {
|
||||||
colors,
|
strings.push(meta.name.render(colors, icons, None));
|
||||||
Some(padding_rules.name_with_symlink - meta.name.name_string(icons).len()),
|
strings.push(meta.indicator.render(&flags));
|
||||||
));
|
strings.push(meta.symlink.render(
|
||||||
|
colors,
|
||||||
|
Some(
|
||||||
|
padding_rules.name_with_symlink
|
||||||
|
- meta.name.name_string(icons).len(),
|
||||||
|
),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
None => {
|
||||||
|
strings.push(meta.name.render(
|
||||||
|
colors,
|
||||||
|
icons,
|
||||||
|
Some(padding_rules.name_with_symlink + 3),
|
||||||
|
));
|
||||||
|
strings.push(meta.indicator.render(&flags));
|
||||||
|
strings.push(meta.symlink.render(colors, None));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
None => {
|
}
|
||||||
strings.push(meta.name.render(
|
|
||||||
colors,
|
|
||||||
icons,
|
|
||||||
Some(padding_rules.name_with_symlink + 3),
|
|
||||||
));
|
|
||||||
strings.push(meta.indicator.render(&flags));
|
|
||||||
strings.push(meta.symlink.render(colors, None));
|
|
||||||
}
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
strings.push(ANSIString::from(" ")); // TODO do not add this space to the end
|
strings.push(ANSIString::from(" ")); // TODO do not add this space to the end
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ pub struct Flags {
|
||||||
pub icon_theme: IconTheme,
|
pub icon_theme: IconTheme,
|
||||||
pub recursion_depth: usize,
|
pub recursion_depth: usize,
|
||||||
pub blocks: Vec<Block>,
|
pub blocks: Vec<Block>,
|
||||||
|
pub no_symlink: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Flags {
|
impl Flags {
|
||||||
|
@ -89,6 +90,7 @@ impl Flags {
|
||||||
}
|
}
|
||||||
None => usize::max_value(),
|
None => usize::max_value(),
|
||||||
};
|
};
|
||||||
|
let no_symlink = matches.is_present("no-symlink");
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
display,
|
display,
|
||||||
|
@ -122,6 +124,7 @@ impl Flags {
|
||||||
} else {
|
} else {
|
||||||
DirOrderFlag::from(dir_order_inputs[dir_order_inputs.len() - 1])
|
DirOrderFlag::from(dir_order_inputs[dir_order_inputs.len() - 1])
|
||||||
},
|
},
|
||||||
|
no_symlink,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -150,6 +153,7 @@ impl Default for Flags {
|
||||||
Block::Date,
|
Block::Date,
|
||||||
Block::Name,
|
Block::Name,
|
||||||
],
|
],
|
||||||
|
no_symlink: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -163,7 +167,6 @@ pub enum Block {
|
||||||
Size,
|
Size,
|
||||||
Date,
|
Date,
|
||||||
Name,
|
Name,
|
||||||
NameWithSymlink,
|
|
||||||
}
|
}
|
||||||
impl<'a> From<&'a str> for Block {
|
impl<'a> From<&'a str> for Block {
|
||||||
fn from(block: &'a str) -> Self {
|
fn from(block: &'a str) -> Self {
|
||||||
|
@ -174,8 +177,7 @@ impl<'a> From<&'a str> for Block {
|
||||||
"group" => Block::Group,
|
"group" => Block::Group,
|
||||||
"size" => Block::Size,
|
"size" => Block::Size,
|
||||||
"date" => Block::Date,
|
"date" => Block::Date,
|
||||||
"name" => Block::NameWithSymlink,
|
"name" => Block::Name,
|
||||||
"namewithoutsymlink" => Block::Name,
|
|
||||||
_ => panic!("invalid \"time\" flag: {}", block),
|
_ => panic!("invalid \"time\" flag: {}", block),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue