mirror of
https://github.com/lsd-rs/lsd
synced 2024-12-14 06:02:36 +00:00
args/inode: 🔨 inode work with long
This commit is contained in:
parent
74660f1d70
commit
7ca7290e23
3 changed files with 13 additions and 4 deletions
|
@ -215,8 +215,7 @@ pub fn build() -> App<'static, 'static> {
|
||||||
.short("i")
|
.short("i")
|
||||||
.long("inode")
|
.long("inode")
|
||||||
.multiple(true)
|
.multiple(true)
|
||||||
.conflicts_with("blocks")
|
.help("Display inode(Linux only)"),
|
||||||
.help("Display inode and file names"),
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -98,8 +98,7 @@ impl Flags {
|
||||||
None => usize::max_value(),
|
None => usize::max_value(),
|
||||||
};
|
};
|
||||||
|
|
||||||
let blocks: Vec<Block> = match () {
|
let mut blocks: Vec<Block> = match () {
|
||||||
_ if inode => vec![Block::INode, Block::Name],
|
|
||||||
_ if !blocks_inputs.is_empty() => blocks_inputs.into_iter().map(Block::from).collect(),
|
_ if !blocks_inputs.is_empty() => blocks_inputs.into_iter().map(Block::from).collect(),
|
||||||
_ if matches.is_present("long") => vec![
|
_ if matches.is_present("long") => vec![
|
||||||
Block::Permission,
|
Block::Permission,
|
||||||
|
@ -112,6 +111,11 @@ impl Flags {
|
||||||
_ => vec![Block::Name],
|
_ => vec![Block::Name],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Add inode as first column if with inode flag
|
||||||
|
if inode && !blocks.contains(&Block::INode) {
|
||||||
|
blocks.insert(0, Block::INode);
|
||||||
|
}
|
||||||
|
|
||||||
let mut ignore_globs_builder = GlobSetBuilder::new();
|
let mut ignore_globs_builder = GlobSetBuilder::new();
|
||||||
for pattern in ignore_globs_inputs {
|
for pattern in ignore_globs_inputs {
|
||||||
let glob = match Glob::new(pattern) {
|
let glob = match Glob::new(pattern) {
|
||||||
|
|
|
@ -128,6 +128,12 @@ fn test_list_block_inode_populated_directory() {
|
||||||
.stdout(predicate::str::is_match(matched).unwrap());
|
.stdout(predicate::str::is_match(matched).unwrap());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_list_inode_with_long_ok() {
|
||||||
|
let dir = tempdir();
|
||||||
|
cmd().arg("-i").arg("-l").arg(dir.path()).assert().success();
|
||||||
|
}
|
||||||
|
|
||||||
fn cmd() -> Command {
|
fn cmd() -> Command {
|
||||||
Command::cargo_bin(env!("CARGO_PKG_NAME")).unwrap()
|
Command::cargo_bin(env!("CARGO_PKG_NAME")).unwrap()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue