diff --git a/src/commands.rs b/src/commands.rs index eb23703..9b76ad3 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -444,6 +444,11 @@ pub fn cmd_predict(gc: Conf, mut sc: ConfPred) -> Result { } } } + let lastskip = totcount.saturating_sub(sc.first); + if sc.show.merge && gc.showskip && lastskip > 0 { + tbl.skiprow(&[&gc.skip, &"(skip last ", &lastskip, &")"]); + } + // Print summary line if totcount > 0 { if sc.show.tot { let mut s: Vec<&dyn Disp> = vec![&"Estimate for ", @@ -454,10 +459,6 @@ pub fn cmd_predict(gc: Conf, mut sc: ConfPred) -> Result { if totunknown > 0 { s.extend::<[&dyn Disp; 5]>([&", ", &gc.cnt, &totunknown, &gc.clr, &" unknown"]); } - let tothidden = totcount.saturating_sub(sc.first.min(last - 1)); - if tothidden > 0 { - s.extend::<[&dyn Disp; 5]>([&", ", &gc.cnt, &tothidden, &gc.clr, &" hidden"]); - } let e = FmtDur(totelapsed); if totelapsed > 0 { s.extend::<[&dyn Disp; 4]>([&", ", &e, &gc.clr, &" elapsed"]); diff --git a/src/config/cli.rs b/src/config/cli.rs index ebf882a..0328da7 100644 --- a/src/config/cli.rs +++ b/src/config/cli.rs @@ -121,8 +121,8 @@ pub fn build_cli() -> Command { .help_heading("Filter") .help("Show only the last entries") .long_help("Show only the last entries\n \ - (empty)|1: last entry\n \ - 5: last 5 entries\n"); + (empty)|1: last entry\n \ + 5: last 5 entries\n"); let h = "Use main, backup, either, or no portage resume list\n\ This is ignored if STDIN is a piped `emerge -p` output\n \ (default)|auto|a: Use main or backup resume list, if currently emerging\n \ diff --git a/tests/commands.rs b/tests/commands.rs index a018d21..157f907 100644 --- a/tests/commands.rs +++ b/tests/commands.rs @@ -211,26 +211,55 @@ fn predict_tty() { #[ignore] #[test] fn predict_emerge_p() { - let t = [// Check garbage input - ("blah blah\n", format!("No pretended merge found\n"), 1), - // Check all-unknowns - ("[ebuild R ~] dev-lang/unknown-1.42\n", - format!("dev-lang/unknown-1.42 ? \n\ - Estimate for 1 ebuild, 1 unknown 10 @ {}\n", - ts(10)), - 0), - // Check that unknown ebuild don't wreck alignment. Remember that times are {:>9} - ("[ebuild R ~] dev-qt/qtcore-5.9.4-r2\n\ + let t = + [// Check garbage input + ("%F10000.log p --date unix -oc", + "blah blah\n", + format!("No pretended merge found\n"), + 1), + // Check all-unknowns + ("%F10000.log p --date unix -oc", + "[ebuild R ~] dev-lang/unknown-1.42\n", + format!("dev-lang/unknown-1.42 ? \n\ + Estimate for 1 ebuild, 1 unknown 10 @ {}\n", + ts(10)), + 0), + // Check that unknown ebuild don't wreck alignment. Remember that times are {:>9} + ("%F10000.log p --date unix -oc", + "[ebuild R ~] dev-qt/qtcore-5.9.4-r2\n\ [ebuild R ~] dev-lang/unknown-1.42\n\ [ebuild R ~] dev-qt/qtgui-5.9.4-r3\n", - format!("dev-qt/qtcore-5.9.4-r2 3:45 \n\ - dev-lang/unknown-1.42 ? \n\ - dev-qt/qtgui-5.9.4-r3 4:24 \n\ - Estimate for 3 ebuilds, 1 unknown 8:19 @ {}\n", - ts(8 * 60 + 9 + 10)), - 0)]; - for (i, o, e) in t { - emlop("%F10000.log p --date unix -oc").write_stdin(i).assert().code(e).stdout(o); + format!("dev-qt/qtcore-5.9.4-r2 3:45 \n\ + dev-lang/unknown-1.42 ? \n\ + dev-qt/qtgui-5.9.4-r3 4:24 \n\ + Estimate for 3 ebuilds, 1 unknown 8:19 @ {}\n", + ts(8 * 60 + 9 + 10)), + 0), + // Check skip rows + ("%F10000.log p --date unix -oc --show m --first 2", + "[ebuild R ~] dev-qt/qtcore-1\n\ + [ebuild R ~] dev-qt/qtcore-2\n\ + [ebuild R ~] dev-qt/qtcore-3\n\ + [ebuild R ~] dev-qt/qtcore-4\n\ + [ebuild R ~] dev-qt/qtcore-5\n", + "dev-qt/qtcore-1 3:45\n\ + dev-qt/qtcore-2 3:45\n\ + (skip last 3) \n" + .into(), + 0), + ("%F10000.log p --date unix -oc --show m --first 2 --last 1", + "[ebuild R ~] dev-qt/qtcore-1\n\ + [ebuild R ~] dev-qt/qtcore-2\n\ + [ebuild R ~] dev-qt/qtcore-3\n\ + [ebuild R ~] dev-qt/qtcore-4\n\ + [ebuild R ~] dev-qt/qtcore-5\n", + "(skip first 1)\n\ + dev-qt/qtcore-2 3:45\n\ + (skip last 3) \n" + .into(), + 0)]; + for (a, i, o, e) in t { + emlop(a).write_stdin(i).assert().code(e).stdout(o); } }