feat(last): add --since and --until (#342)

* feat(last): add --since and --until

* clean up clap slightly

* fix clippy

* test(last): add tests for --since and --until

* refactor(last): resolve review comments

* test(last): set cfg for since and until to unix

* remove unnecessary comment

* move parse_time_value below uumain

* minor cleanup

* fix ci issues
This commit is contained in:
Sebastian Bentmar Holgersson
2025-08-01 16:12:39 +02:00
committed by GitHub
parent 76565e287d
commit b5d6d188bf
6 changed files with 98 additions and 1 deletions
+32
View File
@@ -132,3 +132,35 @@ fn test_display_hostname_last_column() {
assert_eq!(output_expected, output_result);
}
#[test]
#[cfg(all(unix, not(target_os = "macos"), not(target_os = "openbsd")))]
fn test_since_only_shows_entries_after_time() {
let expected_entry_time = "16:29";
let unexpected_entry_time = "16:24";
new_ucmd!()
.arg("--file")
.arg("last.input.1")
.arg("--since")
.arg("2025-03-08 16:28")
.succeeds()
.stdout_contains(expected_entry_time)
.stdout_does_not_contain(unexpected_entry_time);
}
#[test]
#[cfg(all(unix, not(target_os = "macos"), not(target_os = "openbsd")))]
fn test_until_only_shows_entries_before_time() {
let expected_entry_time = "16:24";
let unexpected_entry_time = "16:29";
new_ucmd!()
.arg("--file")
.arg("last.input.1")
.arg("--until")
.arg("2025-03-08 16:28")
.succeeds()
.stdout_contains(expected_entry_time)
.stdout_does_not_contain(unexpected_entry_time);
}