1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

tail: accept shortcuts for stringly-enum arguments

This commit is contained in:
Ben Wiederhake 2024-04-01 08:06:18 +02:00
parent 872ec050e4
commit 88a2ea4f3b
2 changed files with 31 additions and 27 deletions

View file

@ -16,6 +16,7 @@ use std::io::IsTerminal;
use std::time::Duration; use std::time::Duration;
use uucore::error::{UResult, USimpleError, UUsageError}; use uucore::error::{UResult, USimpleError, UUsageError};
use uucore::parse_size::{parse_size_u64, ParseSizeError}; use uucore::parse_size::{parse_size_u64, ParseSizeError};
use uucore::shortcut_value_parser::ShortcutValueParser;
use uucore::{format_usage, help_about, help_usage, show_warning}; use uucore::{format_usage, help_about, help_usage, show_warning};
const ABOUT: &str = help_about!("tail.md"); const ABOUT: &str = help_about!("tail.md");
@ -494,7 +495,7 @@ pub fn uu_app() -> Command {
.default_missing_value("descriptor") .default_missing_value("descriptor")
.num_args(0..=1) .num_args(0..=1)
.require_equals(true) .require_equals(true)
.value_parser(["descriptor", "name"]) .value_parser(ShortcutValueParser::new(["descriptor", "name"]))
.overrides_with(options::FOLLOW) .overrides_with(options::FOLLOW)
.help("Print the file as it grows"), .help("Print the file as it grows"),
) )

View file

@ -533,9 +533,11 @@ fn test_follow_multiple() {
#[test] #[test]
#[cfg(not(target_os = "windows"))] // FIXME: test times out #[cfg(not(target_os = "windows"))] // FIXME: test times out
fn test_follow_name_multiple() { fn test_follow_name_multiple() {
// spell-checker:disable-next-line
for argument in ["--follow=name", "--follo=nam", "--f=n"] {
let (at, mut ucmd) = at_and_ucmd!(); let (at, mut ucmd) = at_and_ucmd!();
let mut child = ucmd let mut child = ucmd
.arg("--follow=name") .arg(argument)
.arg(FOOBAR_TXT) .arg(FOOBAR_TXT)
.arg(FOOBAR_2_TXT) .arg(FOOBAR_2_TXT)
.run_no_wait(); .run_no_wait();
@ -565,6 +567,7 @@ fn test_follow_name_multiple() {
child.make_assertion().is_alive(); child.make_assertion().is_alive();
child.kill(); child.kill();
} }
}
#[test] #[test]
fn test_follow_multiple_untailable() { fn test_follow_multiple_untailable() {
@ -844,7 +847,7 @@ fn test_follow_missing() {
// Ensure that --follow=name does not imply --retry. // Ensure that --follow=name does not imply --retry.
// Ensure that --follow={descriptor,name} (without --retry) does *not wait* for the // Ensure that --follow={descriptor,name} (without --retry) does *not wait* for the
// file to appear. // 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!() new_ucmd!()
.arg(follow_mode) .arg(follow_mode)
.arg("missing") .arg("missing")