1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-27 19:17:43 +00:00

Merge pull request #6955 from cakebaker/bump_clap

Bump `clap` to `4.5.23` & fix failing `seq` tests
This commit is contained in:
Sylvestre Ledru 2024-12-15 17:05:42 +01:00 committed by GitHub
commit aea13edfad
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 61 additions and 26 deletions

41
Cargo.lock generated
View file

@ -61,23 +61,24 @@ dependencies = [
[[package]]
name = "anstream"
version = "0.5.0"
version = "0.6.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1f58811cfac344940f1a400b6e6231ce35171f614f26439e80f8c1465c5cc0c"
checksum = "8acc5369981196006228e28809f761875c0327210a891e941f4c683b3a99529b"
dependencies = [
"anstyle",
"anstyle-parse",
"anstyle-query",
"anstyle-wincon",
"colorchoice",
"is_terminal_polyfill",
"utf8parse",
]
[[package]]
name = "anstyle"
version = "1.0.0"
version = "1.0.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "41ed9a86bf92ae6580e0a31281f65a1b1d867c0cc68d5346e2ae128dddfa6a7d"
checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9"
[[package]]
name = "anstyle-parse"
@ -99,12 +100,12 @@ dependencies = [
[[package]]
name = "anstyle-wincon"
version = "2.1.0"
version = "3.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "58f54d10c6dfa51283a066ceab3ec1ab78d13fae00aa49243a45e4571fb79dfd"
checksum = "2109dbce0e72be3ec00bed26e6a7479ca384ad226efdd66db8fa2e3a38c83125"
dependencies = [
"anstyle",
"windows-sys 0.48.0",
"windows-sys 0.59.0",
]
[[package]]
@ -326,24 +327,24 @@ dependencies = [
[[package]]
name = "clap"
version = "4.4.2"
version = "4.5.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6a13b88d2c62ff462f88e4a121f17a82c1af05693a2f192b5c38d14de73c19f6"
checksum = "3135e7ec2ef7b10c6ed8950f0f792ed96ee093fa088608f1c76e569722700c84"
dependencies = [
"clap_builder",
]
[[package]]
name = "clap_builder"
version = "4.4.2"
version = "4.5.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2bb9faaa7c2ef94b2743a21f5a29e6f0010dff4caa69ac8e9d6cf8b6fa74da08"
checksum = "30582fc632330df2bd26877bde0c1f4470d57c582bbc070376afcd04d8cb4838"
dependencies = [
"anstream",
"anstyle",
"clap_lex",
"strsim",
"terminal_size 0.2.6",
"terminal_size 0.4.1",
]
[[package]]
@ -357,9 +358,9 @@ dependencies = [
[[package]]
name = "clap_lex"
version = "0.5.0"
version = "0.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2da6da31387c7e4ef160ffab6d5e7f00c42626fe39aea70a7b0f1773f7dd6c1b"
checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6"
[[package]]
name = "clap_mangen"
@ -1229,6 +1230,12 @@ dependencies = [
"windows-sys 0.48.0",
]
[[package]]
name = "is_terminal_polyfill"
version = "1.70.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf"
[[package]]
name = "itertools"
version = "0.13.0"
@ -2231,9 +2238,9 @@ dependencies = [
[[package]]
name = "strsim"
version = "0.10.0"
version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
[[package]]
name = "syn"
@ -3673,7 +3680,7 @@ version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb"
dependencies = [
"windows-sys 0.52.0",
"windows-sys 0.59.0",
]
[[package]]

View file

@ -276,7 +276,7 @@ chrono = { version = "0.4.38", default-features = false, features = [
"alloc",
"clock",
] }
clap = { version = "4.4", features = ["wrap_help", "cargo"] }
clap = { version = "4.5", features = ["wrap_help", "cargo"] }
clap_complete = "4.4"
clap_mangen = "0.2"
compare = "0.1.0"

View file

@ -3,6 +3,7 @@
// For the full copyright and license information, please view the LICENSE
// file that was distributed with this source code.
// spell-checker:ignore (ToDO) extendedbigdecimal numberparse
use std::ffi::OsString;
use std::io::{stdout, ErrorKind, Write};
use clap::{crate_version, Arg, ArgAction, Command};
@ -47,9 +48,33 @@ struct SeqOptions<'a> {
/// The elements are (first, increment, last).
type RangeFloat = (ExtendedBigDecimal, ExtendedBigDecimal, ExtendedBigDecimal);
// Turn short args with attached value, for example "-s,", into two args "-s" and "," to make
// them work with clap.
fn split_short_args_with_value(args: impl uucore::Args) -> impl uucore::Args {
let mut v: Vec<OsString> = Vec::new();
for arg in args {
let bytes = arg.as_encoded_bytes();
if bytes.len() > 2
&& (bytes.starts_with(b"-f") || bytes.starts_with(b"-s") || bytes.starts_with(b"-t"))
{
let (short_arg, value) = bytes.split_at(2);
// SAFETY:
// Both `short_arg` and `value` only contain content that originated from `OsStr::as_encoded_bytes`
v.push(unsafe { OsString::from_encoded_bytes_unchecked(short_arg.to_vec()) });
v.push(unsafe { OsString::from_encoded_bytes_unchecked(value.to_vec()) });
} else {
v.push(arg);
}
}
v.into_iter()
}
#[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let matches = uu_app().try_get_matches_from(args)?;
let matches = uu_app().try_get_matches_from(split_short_args_with_value(args))?;
let numbers_option = matches.get_many::<String>(ARG_NUMBERS);
@ -138,7 +163,6 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
pub fn uu_app() -> Command {
Command::new(uucore::util_name())
.trailing_var_arg(true)
.allow_negative_numbers(true)
.infer_long_args(true)
.version(crate_version!())
.about(ABOUT)
@ -169,7 +193,10 @@ pub fn uu_app() -> Command {
.help("use printf style floating-point FORMAT"),
)
.arg(
// we use allow_hyphen_values instead of allow_negative_numbers because clap removed
// the support for "exotic" negative numbers like -.1 (see https://github.com/clap-rs/clap/discussions/5837)
Arg::new(ARG_NUMBERS)
.allow_hyphen_values(true)
.action(ArgAction::Append)
.num_args(1..=3),
)

View file

@ -48,12 +48,12 @@ fn test_hex_rejects_sign_after_identifier() {
.args(&["-0x-123ABC"])
.fails()
.no_stdout()
.stderr_contains("unexpected argument '-0' found");
.usage_error("invalid floating point argument: '-0x-123ABC'");
new_ucmd!()
.args(&["-0x+123ABC"])
.fails()
.no_stdout()
.stderr_contains("unexpected argument '-0' found");
.usage_error("invalid floating point argument: '-0x+123ABC'");
}
#[test]

View file

@ -314,7 +314,7 @@ sed -i -e "s|mv: cannot overwrite 'a/t': Directory not empty|mv: cannot move 'b/
# disable these test cases
sed -i -E "s|^([^#]*2_31.*)$|#\1|g" tests/printf/printf-cov.pl
sed -i -e "s/du: invalid -t argument/du: invalid --threshold argument/" -e "s/du: option requires an argument/error: a value is required for '--threshold <SIZE>' but none was supplied/" -e "/Try 'du --help' for more information./d" tests/du/threshold.sh
sed -i -e "s/du: invalid -t argument/du: invalid --threshold argument/" -e "s/du: option requires an argument/error: a value is required for '--threshold <SIZE>' but none was supplied/" -e "s/Try 'du --help' for more information./\nFor more information, try '--help'./" tests/du/threshold.sh
# Remove the extra output check
sed -i -e "s|Try '\$prog --help' for more information.\\\n||" tests/du/files0-from.pl

View file

@ -1,8 +1,8 @@
diff --git a/tests/factor/factor.pl b/tests/factor/factor.pl
index 6e612e418..f19c06ca0 100755
index b1406c266..3d97cd6a5 100755
--- a/tests/factor/factor.pl
+++ b/tests/factor/factor.pl
@@ -61,12 +61,13 @@ my @Tests =
@@ -61,12 +61,14 @@ my @Tests =
# Map newer glibc diagnostic to expected.
# Also map OpenBSD 5.1's "unknown option" to expected "invalid option".
{ERR_SUBST => q!s/'1'/1/;s/unknown/invalid/!},
@ -10,7 +10,8 @@ index 6e612e418..f19c06ca0 100755
- . "Try '$prog --help' for more information.\n"},
+ {ERR => "error: unexpected argument '-1' found\n\n"
+ . " tip: to pass '-1' as a value, use '-- -1'\n\n"
+ . "Usage: factor [OPTION]... [NUMBER]...\n"},
+ . "Usage: factor [OPTION]... [NUMBER]...\n\n"
+ . "For more information, try '--help'.\n"},
{EXIT => 1}],
['cont', 'a 4',
{OUT => "4: 2 2\n"},