mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
Merge branch 'main' into ls-version-cmp
This commit is contained in:
commit
e5331e3abb
8 changed files with 41 additions and 34 deletions
8
Cargo.lock
generated
8
Cargo.lock
generated
|
@ -915,18 +915,18 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "fundu"
|
||||
version = "1.1.0"
|
||||
version = "1.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d579dcb632d86591bdd7fc445e705b96cb2a7fb5488d918d956f392b6148e898"
|
||||
checksum = "34804ed59f10b3a630c79822ebf7370b562b7281028369e9baa40547c17f8bdc"
|
||||
dependencies = [
|
||||
"fundu-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fundu-core"
|
||||
version = "0.1.0"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a363b75dd1e4b5bd2cdc305c47399c524cae24638b368b66b1a4c2a36482801f"
|
||||
checksum = "71a99190954ca83bade03ba054799b17a158ea948a6855c6bb8121adb6b49d9f"
|
||||
|
||||
[[package]]
|
||||
name = "futures"
|
||||
|
|
|
@ -280,7 +280,7 @@ filetime = "0.2"
|
|||
fnv = "1.0.7"
|
||||
fs_extra = "1.3.0"
|
||||
fts-sys = "0.2"
|
||||
fundu = "1.1.0"
|
||||
fundu = "1.2.0"
|
||||
gcd = "2.3"
|
||||
glob = "0.3.1"
|
||||
half = "2.2"
|
||||
|
|
|
@ -1202,6 +1202,7 @@ pub fn uu_app() -> Command {
|
|||
Arg::new(options::quoting::LITERAL)
|
||||
.short('N')
|
||||
.long(options::quoting::LITERAL)
|
||||
.alias("l")
|
||||
.help("Use literal quoting style. Equivalent to `--quoting-style=literal`")
|
||||
.overrides_with_all([
|
||||
options::QUOTING_STYLE,
|
||||
|
|
|
@ -165,7 +165,7 @@ pub fn uu_app() -> Command {
|
|||
.short('b')
|
||||
.long(options::BODY_NUMBERING)
|
||||
.help("use STYLE for numbering body lines")
|
||||
.value_name("SYNTAX"),
|
||||
.value_name("STYLE"),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(options::SECTION_DELIMITER)
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// *
|
||||
// * For the full copyright and license information, please view the LICENSE
|
||||
// * file that was distributed with this source code.
|
||||
// spell-checker:ignore numberparse argtype
|
||||
// spell-checker:ignore numberparse
|
||||
//! Errors returned by seq.
|
||||
use std::error::Error;
|
||||
use std::fmt::Display;
|
||||
|
@ -25,29 +25,11 @@ pub enum SeqError {
|
|||
/// The parameter is the increment argument as a [`String`] as read
|
||||
/// from the command line.
|
||||
ZeroIncrement(String),
|
||||
|
||||
/// No arguments were passed to this function, 1 or more is required
|
||||
NoArguments,
|
||||
}
|
||||
|
||||
impl SeqError {
|
||||
/// The [`String`] argument as read from the command-line.
|
||||
fn arg(&self) -> &str {
|
||||
match self {
|
||||
Self::ParseError(s, _) => s,
|
||||
Self::ZeroIncrement(s) => s,
|
||||
}
|
||||
}
|
||||
|
||||
/// The type of argument that is causing the error.
|
||||
fn argtype(&self) -> &str {
|
||||
match self {
|
||||
Self::ParseError(_, e) => match e {
|
||||
ParseNumberError::Float => "floating point argument",
|
||||
ParseNumberError::Nan => "'not-a-number' argument",
|
||||
ParseNumberError::Hex => "hexadecimal argument",
|
||||
},
|
||||
Self::ZeroIncrement(_) => "Zero increment value",
|
||||
}
|
||||
}
|
||||
}
|
||||
impl UError for SeqError {
|
||||
/// Always return 1.
|
||||
fn code(&self) -> i32 {
|
||||
|
@ -63,6 +45,17 @@ impl Error for SeqError {}
|
|||
|
||||
impl Display for SeqError {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "invalid {}: {}", self.argtype(), self.arg().quote())
|
||||
match self {
|
||||
Self::ParseError(s, e) => {
|
||||
let error_type = match e {
|
||||
ParseNumberError::Float => "floating point",
|
||||
ParseNumberError::Nan => "'not-a-number'",
|
||||
ParseNumberError::Hex => "hexadecimal",
|
||||
};
|
||||
write!(f, "invalid {error_type} argument: {}", s.quote())
|
||||
}
|
||||
Self::ZeroIncrement(s) => write!(f, "invalid Zero increment value: {}", s.quote()),
|
||||
Self::NoArguments => write!(f, "missing operand"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,10 +58,13 @@ type RangeFloat = (ExtendedBigDecimal, ExtendedBigDecimal, ExtendedBigDecimal);
|
|||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
let matches = uu_app().try_get_matches_from(args)?;
|
||||
|
||||
let numbers = matches
|
||||
.get_many::<String>(ARG_NUMBERS)
|
||||
.unwrap()
|
||||
.collect::<Vec<_>>();
|
||||
let numbers_option = matches.get_many::<String>(ARG_NUMBERS);
|
||||
|
||||
if numbers_option.is_none() {
|
||||
return Err(SeqError::NoArguments.into());
|
||||
}
|
||||
|
||||
let numbers = numbers_option.unwrap().collect::<Vec<_>>();
|
||||
|
||||
let options = SeqOptions {
|
||||
separator: matches
|
||||
|
|
|
@ -22,7 +22,6 @@ use std::time::Duration;
|
|||
const LONG_ARGS: &[&str] = &[
|
||||
"-l",
|
||||
"--long",
|
||||
"--l",
|
||||
"--format=long",
|
||||
"--for=long",
|
||||
"--format=verbose",
|
||||
|
@ -2370,6 +2369,7 @@ fn test_ls_quoting_style() {
|
|||
("--quoting-style=literal", "one?two"),
|
||||
("-N", "one?two"),
|
||||
("--literal", "one?two"),
|
||||
("--l", "one?two"),
|
||||
("--quoting-style=c", "\"one\\ntwo\""),
|
||||
("-Q", "\"one\\ntwo\""),
|
||||
("--quote-name", "\"one\\ntwo\""),
|
||||
|
@ -2394,6 +2394,7 @@ fn test_ls_quoting_style() {
|
|||
("--quoting-style=literal", "one\ntwo"),
|
||||
("-N", "one\ntwo"),
|
||||
("--literal", "one\ntwo"),
|
||||
("--l", "one\ntwo"),
|
||||
("--quoting-style=shell", "one\ntwo"), // FIXME: GNU ls quotes this case
|
||||
("--quoting-style=shell-always", "'one\ntwo'"),
|
||||
] {
|
||||
|
@ -2455,6 +2456,7 @@ fn test_ls_quoting_style() {
|
|||
("--quoting-style=literal", "one two"),
|
||||
("-N", "one two"),
|
||||
("--literal", "one two"),
|
||||
("--l", "one two"),
|
||||
("--quoting-style=c", "\"one two\""),
|
||||
("-Q", "\"one two\""),
|
||||
("--quote-name", "\"one two\""),
|
||||
|
|
|
@ -7,6 +7,14 @@ fn test_invalid_arg() {
|
|||
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_no_args() {
|
||||
new_ucmd!()
|
||||
.fails()
|
||||
.code_is(1)
|
||||
.stderr_contains("missing operand");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_hex_rejects_sign_after_identifier() {
|
||||
new_ucmd!()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue