mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 03:27:44 +00:00
tail: accept shortcuts for stringly-enum arguments
This commit is contained in:
parent
872ec050e4
commit
88a2ea4f3b
2 changed files with 31 additions and 27 deletions
|
@ -16,6 +16,7 @@ use std::io::IsTerminal;
|
|||
use std::time::Duration;
|
||||
use uucore::error::{UResult, USimpleError, UUsageError};
|
||||
use uucore::parse_size::{parse_size_u64, ParseSizeError};
|
||||
use uucore::shortcut_value_parser::ShortcutValueParser;
|
||||
use uucore::{format_usage, help_about, help_usage, show_warning};
|
||||
|
||||
const ABOUT: &str = help_about!("tail.md");
|
||||
|
@ -494,7 +495,7 @@ pub fn uu_app() -> Command {
|
|||
.default_missing_value("descriptor")
|
||||
.num_args(0..=1)
|
||||
.require_equals(true)
|
||||
.value_parser(["descriptor", "name"])
|
||||
.value_parser(ShortcutValueParser::new(["descriptor", "name"]))
|
||||
.overrides_with(options::FOLLOW)
|
||||
.help("Print the file as it grows"),
|
||||
)
|
||||
|
|
|
@ -533,37 +533,40 @@ fn test_follow_multiple() {
|
|||
#[test]
|
||||
#[cfg(not(target_os = "windows"))] // FIXME: test times out
|
||||
fn test_follow_name_multiple() {
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
let mut child = ucmd
|
||||
.arg("--follow=name")
|
||||
.arg(FOOBAR_TXT)
|
||||
.arg(FOOBAR_2_TXT)
|
||||
.run_no_wait();
|
||||
// spell-checker:disable-next-line
|
||||
for argument in ["--follow=name", "--follo=nam", "--f=n"] {
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
let mut child = ucmd
|
||||
.arg(argument)
|
||||
.arg(FOOBAR_TXT)
|
||||
.arg(FOOBAR_2_TXT)
|
||||
.run_no_wait();
|
||||
|
||||
child
|
||||
.make_assertion_with_delay(500)
|
||||
.is_alive()
|
||||
.with_current_output()
|
||||
.stdout_only_fixture("foobar_follow_multiple.expected");
|
||||
child
|
||||
.make_assertion_with_delay(500)
|
||||
.is_alive()
|
||||
.with_current_output()
|
||||
.stdout_only_fixture("foobar_follow_multiple.expected");
|
||||
|
||||
let first_append = "trois\n";
|
||||
at.append(FOOBAR_2_TXT, first_append);
|
||||
let first_append = "trois\n";
|
||||
at.append(FOOBAR_2_TXT, first_append);
|
||||
|
||||
child
|
||||
.make_assertion_with_delay(DEFAULT_SLEEP_INTERVAL_MILLIS)
|
||||
.with_current_output()
|
||||
.stdout_only(first_append);
|
||||
child
|
||||
.make_assertion_with_delay(DEFAULT_SLEEP_INTERVAL_MILLIS)
|
||||
.with_current_output()
|
||||
.stdout_only(first_append);
|
||||
|
||||
let second_append = "twenty\nthirty\n";
|
||||
at.append(FOOBAR_TXT, second_append);
|
||||
let second_append = "twenty\nthirty\n";
|
||||
at.append(FOOBAR_TXT, second_append);
|
||||
|
||||
child
|
||||
.make_assertion_with_delay(DEFAULT_SLEEP_INTERVAL_MILLIS)
|
||||
.with_current_output()
|
||||
.stdout_only_fixture("foobar_follow_multiple_appended.expected");
|
||||
child
|
||||
.make_assertion_with_delay(DEFAULT_SLEEP_INTERVAL_MILLIS)
|
||||
.with_current_output()
|
||||
.stdout_only_fixture("foobar_follow_multiple_appended.expected");
|
||||
|
||||
child.make_assertion().is_alive();
|
||||
child.kill();
|
||||
child.make_assertion().is_alive();
|
||||
child.kill();
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -844,7 +847,7 @@ fn test_follow_missing() {
|
|||
// Ensure that --follow=name does not imply --retry.
|
||||
// Ensure that --follow={descriptor,name} (without --retry) does *not wait* for the
|
||||
// file to appear.
|
||||
for follow_mode in &["--follow=descriptor", "--follow=name"] {
|
||||
for follow_mode in &["--follow=descriptor", "--follow=name", "--fo=d", "--fo=n"] {
|
||||
new_ucmd!()
|
||||
.arg(follow_mode)
|
||||
.arg("missing")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue