summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2017-12-03 22:23:44 +0100
committerGitHub <noreply@github.com>2017-12-03 22:23:44 +0100
commitb1cf058dccdfdc170211f705ff188bd52670e32b (patch)
treedf72f9211fdbd1550a4ad9cab2ededad00c463a3
parent72710323d0bfdbb5c675d5b27acd588f9730dd36 (diff)
parentb17772041f9306bc4b9a66d35c11066e91c6c12e (diff)
downloadimag-b1cf058dccdfdc170211f705ff188bd52670e32b.zip
imag-b1cf058dccdfdc170211f705ff188bd52670e32b.tar.gz
Merge pull request #1165 from matthiasbeyer/libimagentrylist/with-idx-fix
TableLister: If configured with index, also print index row
-rw-r--r--lib/entry/libimagentrylist/src/listers/table.rs6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/entry/libimagentrylist/src/listers/table.rs b/lib/entry/libimagentrylist/src/listers/table.rs
index 3bb58b9..46585c6 100644
--- a/lib/entry/libimagentrylist/src/listers/table.rs
+++ b/lib/entry/libimagentrylist/src/listers/table.rs
@@ -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)
})