Merge pull request #1165 from matthiasbeyer/libimagentrylist/with-idx-fix
TableLister: If configured with index, also print index row
This commit is contained in:
commit
b1cf058dcc
1 changed files with 5 additions and 1 deletions
|
@ -81,7 +81,7 @@ impl<F: Fn(&FileLockEntry) -> Vec<String>> Lister for TableLister<F> {
|
|||
},
|
||||
}
|
||||
|
||||
entries.fold(Ok(table), |table, entry| {
|
||||
entries.enumerate().fold(Ok(table), |table, (i, entry)| {
|
||||
table.and_then(|mut table| {
|
||||
let mut v = (self.line_generator)(&entry);
|
||||
{
|
||||
|
@ -97,6 +97,10 @@ impl<F: Fn(&FileLockEntry) -> Vec<String>> Lister for TableLister<F> {
|
|||
}
|
||||
}
|
||||
|
||||
if self.with_idx {
|
||||
v.insert(0, format!("{}", i));
|
||||
}
|
||||
|
||||
table.add_row(v.iter().map(|s| Cell::new(s)).collect());
|
||||
Ok(table)
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue