mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 03:27:44 +00:00
uucore: Move parser to a feature
This will eventually be needed as we'll want parse_time to call into num_parser, which was previously contained in format feature.
This commit is contained in:
parent
a937aa5117
commit
6243dd5494
63 changed files with 90 additions and 79 deletions
|
@ -15,7 +15,7 @@ tempfile = "3.15.0"
|
||||||
rand = { version = "0.9.0", features = ["small_rng"] }
|
rand = { version = "0.9.0", features = ["small_rng"] }
|
||||||
similar = "2.5.0"
|
similar = "2.5.0"
|
||||||
|
|
||||||
uucore = { path = "../src/uucore/" }
|
uucore = { path = "../src/uucore/", features = ["parser"] }
|
||||||
uu_date = { path = "../src/uu/date/" }
|
uu_date = { path = "../src/uu/date/" }
|
||||||
uu_test = { path = "../src/uu/test/" }
|
uu_test = { path = "../src/uu/test/" }
|
||||||
uu_expr = { path = "../src/uu/expr/" }
|
uu_expr = { path = "../src/uu/expr/" }
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#![no_main]
|
#![no_main]
|
||||||
|
|
||||||
use libfuzzer_sys::fuzz_target;
|
use libfuzzer_sys::fuzz_target;
|
||||||
use uucore::parse_glob;
|
use uucore::parser::parse_glob;
|
||||||
|
|
||||||
fuzz_target!(|data: &[u8]| {
|
fuzz_target!(|data: &[u8]| {
|
||||||
if let Ok(s) = std::str::from_utf8(data) {
|
if let Ok(s) = std::str::from_utf8(data) {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#![no_main]
|
#![no_main]
|
||||||
|
|
||||||
use libfuzzer_sys::fuzz_target;
|
use libfuzzer_sys::fuzz_target;
|
||||||
use uucore::parse_size::parse_size_u64;
|
use uucore::parser::parse_size::parse_size_u64;
|
||||||
|
|
||||||
fuzz_target!(|data: &[u8]| {
|
fuzz_target!(|data: &[u8]| {
|
||||||
if let Ok(s) = std::str::from_utf8(data) {
|
if let Ok(s) = std::str::from_utf8(data) {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#![no_main]
|
#![no_main]
|
||||||
|
|
||||||
use libfuzzer_sys::fuzz_target;
|
use libfuzzer_sys::fuzz_target;
|
||||||
use uucore::parse_time;
|
use uucore::parser::parse_time;
|
||||||
|
|
||||||
fuzz_target!(|data: &[u8]| {
|
fuzz_target!(|data: &[u8]| {
|
||||||
if let Ok(s) = std::str::from_utf8(data) {
|
if let Ok(s) = std::str::from_utf8(data) {
|
||||||
|
|
|
@ -33,6 +33,7 @@ uucore = { workspace = true, features = [
|
||||||
"entries",
|
"entries",
|
||||||
"fs",
|
"fs",
|
||||||
"fsxattr",
|
"fsxattr",
|
||||||
|
"parser",
|
||||||
"perms",
|
"perms",
|
||||||
"mode",
|
"mode",
|
||||||
"update-control",
|
"update-control",
|
||||||
|
|
|
@ -40,8 +40,8 @@ use uucore::{backup_control, update_control};
|
||||||
// requires these enum.
|
// requires these enum.
|
||||||
pub use uucore::{backup_control::BackupMode, update_control::UpdateMode};
|
pub use uucore::{backup_control::BackupMode, update_control::UpdateMode};
|
||||||
use uucore::{
|
use uucore::{
|
||||||
format_usage, help_about, help_section, help_usage, prompt_yes,
|
format_usage, help_about, help_section, help_usage,
|
||||||
shortcut_value_parser::ShortcutValueParser, show_error, show_warning,
|
parser::shortcut_value_parser::ShortcutValueParser, prompt_yes, show_error, show_warning,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::copydir::copy_directory;
|
use crate::copydir::copy_directory;
|
||||||
|
|
|
@ -20,7 +20,7 @@ path = "src/date.rs"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
chrono = { workspace = true }
|
chrono = { workspace = true }
|
||||||
clap = { workspace = true }
|
clap = { workspace = true }
|
||||||
uucore = { workspace = true, features = ["custom-tz-fmt"] }
|
uucore = { workspace = true, features = ["custom-tz-fmt", "parser"] }
|
||||||
parse_datetime = { workspace = true }
|
parse_datetime = { workspace = true }
|
||||||
|
|
||||||
[target.'cfg(unix)'.dependencies]
|
[target.'cfg(unix)'.dependencies]
|
||||||
|
|
|
@ -23,7 +23,7 @@ use uucore::{format_usage, help_about, help_usage, show};
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
use windows_sys::Win32::{Foundation::SYSTEMTIME, System::SystemInformation::SetSystemTime};
|
use windows_sys::Win32::{Foundation::SYSTEMTIME, System::SystemInformation::SetSystemTime};
|
||||||
|
|
||||||
use uucore::shortcut_value_parser::ShortcutValueParser;
|
use uucore::parser::shortcut_value_parser::ShortcutValueParser;
|
||||||
|
|
||||||
// Options
|
// Options
|
||||||
const DATE: &str = "date";
|
const DATE: &str = "date";
|
||||||
|
|
|
@ -20,7 +20,7 @@ path = "src/dd.rs"
|
||||||
clap = { workspace = true }
|
clap = { workspace = true }
|
||||||
gcd = { workspace = true }
|
gcd = { workspace = true }
|
||||||
libc = { workspace = true }
|
libc = { workspace = true }
|
||||||
uucore = { workspace = true, features = ["format", "quoting-style"] }
|
uucore = { workspace = true, features = ["format", "parser", "quoting-style"] }
|
||||||
thiserror = { workspace = true }
|
thiserror = { workspace = true }
|
||||||
|
|
||||||
[target.'cfg(any(target_os = "linux", target_os = "android"))'.dependencies]
|
[target.'cfg(any(target_os = "linux", target_os = "android"))'.dependencies]
|
||||||
|
|
|
@ -12,7 +12,7 @@ use crate::conversion_tables::ConversionTable;
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
use uucore::display::Quotable;
|
use uucore::display::Quotable;
|
||||||
use uucore::error::UError;
|
use uucore::error::UError;
|
||||||
use uucore::parse_size::{ParseSizeError, Parser as SizeParser};
|
use uucore::parser::parse_size::{ParseSizeError, Parser as SizeParser};
|
||||||
use uucore::show_warning;
|
use uucore::show_warning;
|
||||||
|
|
||||||
/// Parser Errors describe errors with parser input
|
/// Parser Errors describe errors with parser input
|
||||||
|
|
|
@ -18,7 +18,7 @@ path = "src/df.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
clap = { workspace = true }
|
clap = { workspace = true }
|
||||||
uucore = { workspace = true, features = ["libc", "fsext"] }
|
uucore = { workspace = true, features = ["libc", "fsext", "parser"] }
|
||||||
unicode-width = { workspace = true }
|
unicode-width = { workspace = true }
|
||||||
thiserror = { workspace = true }
|
thiserror = { workspace = true }
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ use std::{env, fmt};
|
||||||
|
|
||||||
use uucore::{
|
use uucore::{
|
||||||
display::Quotable,
|
display::Quotable,
|
||||||
parse_size::{ParseSizeError, parse_size_u64},
|
parser::parse_size::{ParseSizeError, parse_size_u64},
|
||||||
};
|
};
|
||||||
|
|
||||||
/// The first ten powers of 1024.
|
/// The first ten powers of 1024.
|
||||||
|
|
|
@ -14,7 +14,7 @@ use table::HeaderMode;
|
||||||
use uucore::display::Quotable;
|
use uucore::display::Quotable;
|
||||||
use uucore::error::{UError, UResult, USimpleError};
|
use uucore::error::{UError, UResult, USimpleError};
|
||||||
use uucore::fsext::{MountInfo, read_fs_list};
|
use uucore::fsext::{MountInfo, read_fs_list};
|
||||||
use uucore::parse_size::ParseSizeError;
|
use uucore::parser::parse_size::ParseSizeError;
|
||||||
use uucore::{format_usage, help_about, help_section, help_usage, show};
|
use uucore::{format_usage, help_about, help_section, help_usage, show};
|
||||||
|
|
||||||
use clap::{Arg, ArgAction, ArgMatches, Command, parser::ValueSource};
|
use clap::{Arg, ArgAction, ArgMatches, Command, parser::ValueSource};
|
||||||
|
|
|
@ -18,7 +18,7 @@ path = "src/dircolors.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
clap = { workspace = true }
|
clap = { workspace = true }
|
||||||
uucore = { workspace = true, features = ["colors"] }
|
uucore = { workspace = true, features = ["colors", "parser"] }
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "dircolors"
|
name = "dircolors"
|
||||||
|
|
|
@ -15,7 +15,7 @@ use clap::{Arg, ArgAction, Command};
|
||||||
use uucore::colors::{FILE_ATTRIBUTE_CODES, FILE_COLORS, FILE_TYPES, TERMS};
|
use uucore::colors::{FILE_ATTRIBUTE_CODES, FILE_COLORS, FILE_TYPES, TERMS};
|
||||||
use uucore::display::Quotable;
|
use uucore::display::Quotable;
|
||||||
use uucore::error::{UResult, USimpleError, UUsageError};
|
use uucore::error::{UResult, USimpleError, UUsageError};
|
||||||
use uucore::{format_usage, help_about, help_section, help_usage, parse_glob};
|
use uucore::{format_usage, help_about, help_section, help_usage, parser::parse_glob};
|
||||||
|
|
||||||
mod options {
|
mod options {
|
||||||
pub const BOURNE_SHELL: &str = "bourne-shell";
|
pub const BOURNE_SHELL: &str = "bourne-shell";
|
||||||
|
|
|
@ -21,7 +21,7 @@ chrono = { workspace = true }
|
||||||
# For the --exclude & --exclude-from options
|
# For the --exclude & --exclude-from options
|
||||||
glob = { workspace = true }
|
glob = { workspace = true }
|
||||||
clap = { workspace = true }
|
clap = { workspace = true }
|
||||||
uucore = { workspace = true, features = ["format"] }
|
uucore = { workspace = true, features = ["format", "parser"] }
|
||||||
thiserror = { workspace = true }
|
thiserror = { workspace = true }
|
||||||
|
|
||||||
[target.'cfg(target_os = "windows")'.dependencies]
|
[target.'cfg(target_os = "windows")'.dependencies]
|
||||||
|
|
|
@ -27,9 +27,9 @@ use thiserror::Error;
|
||||||
use uucore::display::{Quotable, print_verbatim};
|
use uucore::display::{Quotable, print_verbatim};
|
||||||
use uucore::error::{FromIo, UError, UResult, USimpleError, set_exit_code};
|
use uucore::error::{FromIo, UError, UResult, USimpleError, set_exit_code};
|
||||||
use uucore::line_ending::LineEnding;
|
use uucore::line_ending::LineEnding;
|
||||||
use uucore::parse_glob;
|
use uucore::parser::parse_glob;
|
||||||
use uucore::parse_size::{ParseSizeError, parse_size_u64};
|
use uucore::parser::parse_size::{ParseSizeError, parse_size_u64};
|
||||||
use uucore::shortcut_value_parser::ShortcutValueParser;
|
use uucore::parser::shortcut_value_parser::ShortcutValueParser;
|
||||||
use uucore::{format_usage, help_about, help_section, help_usage, show, show_error, show_warning};
|
use uucore::{format_usage, help_about, help_section, help_usage, show, show_error, show_warning};
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
use windows_sys::Win32::Foundation::HANDLE;
|
use windows_sys::Win32::Foundation::HANDLE;
|
||||||
|
|
|
@ -20,7 +20,12 @@ path = "src/head.rs"
|
||||||
clap = { workspace = true }
|
clap = { workspace = true }
|
||||||
memchr = { workspace = true }
|
memchr = { workspace = true }
|
||||||
thiserror = { workspace = true }
|
thiserror = { workspace = true }
|
||||||
uucore = { workspace = true, features = ["ringbuffer", "lines", "fs"] }
|
uucore = { workspace = true, features = [
|
||||||
|
"parser",
|
||||||
|
"ringbuffer",
|
||||||
|
"lines",
|
||||||
|
"fs",
|
||||||
|
] }
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "head"
|
name = "head"
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
// file that was distributed with this source code.
|
// file that was distributed with this source code.
|
||||||
|
|
||||||
use std::ffi::OsString;
|
use std::ffi::OsString;
|
||||||
use uucore::parse_size::{ParseSizeError, parse_size_u64};
|
use uucore::parser::parse_size::{ParseSizeError, parse_size_u64};
|
||||||
|
|
||||||
#[derive(PartialEq, Eq, Debug)]
|
#[derive(PartialEq, Eq, Debug)]
|
||||||
pub enum ParseError {
|
pub enum ParseError {
|
||||||
|
|
|
@ -34,6 +34,7 @@ uucore = { workspace = true, features = [
|
||||||
"format",
|
"format",
|
||||||
"fs",
|
"fs",
|
||||||
"fsxattr",
|
"fsxattr",
|
||||||
|
"parser",
|
||||||
"quoting-style",
|
"quoting-style",
|
||||||
"version-cmp",
|
"version-cmp",
|
||||||
] }
|
] }
|
||||||
|
|
|
@ -63,11 +63,13 @@ use uucore::{
|
||||||
format_usage,
|
format_usage,
|
||||||
fs::display_permissions,
|
fs::display_permissions,
|
||||||
os_str_as_bytes_lossy,
|
os_str_as_bytes_lossy,
|
||||||
parse_size::parse_size_u64,
|
parser::parse_size::parse_size_u64,
|
||||||
shortcut_value_parser::ShortcutValueParser,
|
parser::shortcut_value_parser::ShortcutValueParser,
|
||||||
version_cmp::version_cmp,
|
version_cmp::version_cmp,
|
||||||
};
|
};
|
||||||
use uucore::{help_about, help_section, help_usage, parse_glob, show, show_error, show_warning};
|
use uucore::{
|
||||||
|
help_about, help_section, help_usage, parser::parse_glob, show, show_error, show_warning,
|
||||||
|
};
|
||||||
|
|
||||||
mod dired;
|
mod dired;
|
||||||
use dired::{DiredOutput, is_dired_arg_present};
|
use dired::{DiredOutput, is_dired_arg_present};
|
||||||
|
|
|
@ -18,7 +18,7 @@ path = "src/numfmt.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
clap = { workspace = true }
|
clap = { workspace = true }
|
||||||
uucore = { workspace = true, features = ["ranges"] }
|
uucore = { workspace = true, features = ["parser", "ranges"] }
|
||||||
thiserror = { workspace = true }
|
thiserror = { workspace = true }
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
|
|
|
@ -14,8 +14,8 @@ use std::str::FromStr;
|
||||||
use units::{IEC_BASES, SI_BASES};
|
use units::{IEC_BASES, SI_BASES};
|
||||||
use uucore::display::Quotable;
|
use uucore::display::Quotable;
|
||||||
use uucore::error::UResult;
|
use uucore::error::UResult;
|
||||||
|
use uucore::parser::shortcut_value_parser::ShortcutValueParser;
|
||||||
use uucore::ranges::Range;
|
use uucore::ranges::Range;
|
||||||
use uucore::shortcut_value_parser::ShortcutValueParser;
|
|
||||||
use uucore::{format_usage, help_about, help_section, help_usage, show, show_error};
|
use uucore::{format_usage, help_about, help_section, help_usage, show, show_error};
|
||||||
|
|
||||||
pub mod errors;
|
pub mod errors;
|
||||||
|
|
|
@ -20,7 +20,7 @@ path = "src/od.rs"
|
||||||
byteorder = { workspace = true }
|
byteorder = { workspace = true }
|
||||||
clap = { workspace = true }
|
clap = { workspace = true }
|
||||||
half = { workspace = true }
|
half = { workspace = true }
|
||||||
uucore = { workspace = true }
|
uucore = { workspace = true, features = ["parser"] }
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "od"
|
name = "od"
|
||||||
|
|
|
@ -43,8 +43,8 @@ use clap::ArgAction;
|
||||||
use clap::{Arg, ArgMatches, Command, parser::ValueSource};
|
use clap::{Arg, ArgMatches, Command, parser::ValueSource};
|
||||||
use uucore::display::Quotable;
|
use uucore::display::Quotable;
|
||||||
use uucore::error::{UResult, USimpleError};
|
use uucore::error::{UResult, USimpleError};
|
||||||
use uucore::parse_size::ParseSizeError;
|
use uucore::parser::parse_size::ParseSizeError;
|
||||||
use uucore::shortcut_value_parser::ShortcutValueParser;
|
use uucore::parser::shortcut_value_parser::ShortcutValueParser;
|
||||||
use uucore::{format_usage, help_about, help_section, help_usage, show_error, show_warning};
|
use uucore::{format_usage, help_about, help_section, help_usage, show_error, show_warning};
|
||||||
|
|
||||||
const PEEK_BUFFER_SIZE: usize = 4; // utf-8 can be 4 bytes
|
const PEEK_BUFFER_SIZE: usize = 4; // utf-8 can be 4 bytes
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
//
|
//
|
||||||
// For the full copyright and license information, please view the LICENSE
|
// For the full copyright and license information, please view the LICENSE
|
||||||
// file that was distributed with this source code.
|
// file that was distributed with this source code.
|
||||||
use uucore::parse_size::{ParseSizeError, parse_size_u64};
|
use uucore::parser::parse_size::{ParseSizeError, parse_size_u64};
|
||||||
|
|
||||||
pub fn parse_number_of_bytes(s: &str) -> Result<u64, ParseSizeError> {
|
pub fn parse_number_of_bytes(s: &str) -> Result<u64, ParseSizeError> {
|
||||||
let mut start = 0;
|
let mut start = 0;
|
||||||
|
|
|
@ -26,6 +26,7 @@ thiserror = { workspace = true }
|
||||||
uucore = { workspace = true, features = [
|
uucore = { workspace = true, features = [
|
||||||
"extendedbigdecimal",
|
"extendedbigdecimal",
|
||||||
"format",
|
"format",
|
||||||
|
"parser",
|
||||||
"quoting-style",
|
"quoting-style",
|
||||||
] }
|
] }
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
//! [`PreciseNumber`] struct.
|
//! [`PreciseNumber`] struct.
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
use uucore::format::num_parser::{ExtendedParser, ExtendedParserError};
|
use uucore::parser::num_parser::{ExtendedParser, ExtendedParserError};
|
||||||
|
|
||||||
use crate::number::PreciseNumber;
|
use crate::number::PreciseNumber;
|
||||||
use uucore::extendedbigdecimal::ExtendedBigDecimal;
|
use uucore::extendedbigdecimal::ExtendedBigDecimal;
|
||||||
|
|
|
@ -19,7 +19,7 @@ path = "src/shred.rs"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
clap = { workspace = true }
|
clap = { workspace = true }
|
||||||
rand = { workspace = true }
|
rand = { workspace = true }
|
||||||
uucore = { workspace = true }
|
uucore = { workspace = true, features = ["parser"] }
|
||||||
libc = { workspace = true }
|
libc = { workspace = true }
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
|
|
|
@ -16,8 +16,8 @@ use std::os::unix::prelude::PermissionsExt;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use uucore::display::Quotable;
|
use uucore::display::Quotable;
|
||||||
use uucore::error::{FromIo, UResult, USimpleError, UUsageError};
|
use uucore::error::{FromIo, UResult, USimpleError, UUsageError};
|
||||||
use uucore::parse_size::parse_size_u64;
|
use uucore::parser::parse_size::parse_size_u64;
|
||||||
use uucore::shortcut_value_parser::ShortcutValueParser;
|
use uucore::parser::shortcut_value_parser::ShortcutValueParser;
|
||||||
use uucore::{format_usage, help_about, help_section, help_usage, show_error, show_if_err};
|
use uucore::{format_usage, help_about, help_section, help_usage, show_error, show_if_err};
|
||||||
|
|
||||||
const ABOUT: &str = help_about!("shred.md");
|
const ABOUT: &str = help_about!("shred.md");
|
||||||
|
|
|
@ -30,7 +30,7 @@ self_cell = { workspace = true }
|
||||||
tempfile = { workspace = true }
|
tempfile = { workspace = true }
|
||||||
thiserror = { workspace = true }
|
thiserror = { workspace = true }
|
||||||
unicode-width = { workspace = true }
|
unicode-width = { workspace = true }
|
||||||
uucore = { workspace = true, features = ["fs", "version-cmp"] }
|
uucore = { workspace = true, features = ["fs", "parser", "version-cmp"] }
|
||||||
|
|
||||||
[target.'cfg(target_os = "linux")'.dependencies]
|
[target.'cfg(target_os = "linux")'.dependencies]
|
||||||
nix = { workspace = true }
|
nix = { workspace = true }
|
||||||
|
|
|
@ -45,8 +45,8 @@ use uucore::display::Quotable;
|
||||||
use uucore::error::strip_errno;
|
use uucore::error::strip_errno;
|
||||||
use uucore::error::{UError, UResult, USimpleError, UUsageError, set_exit_code};
|
use uucore::error::{UError, UResult, USimpleError, UUsageError, set_exit_code};
|
||||||
use uucore::line_ending::LineEnding;
|
use uucore::line_ending::LineEnding;
|
||||||
use uucore::parse_size::{ParseSizeError, Parser};
|
use uucore::parser::parse_size::{ParseSizeError, Parser};
|
||||||
use uucore::shortcut_value_parser::ShortcutValueParser;
|
use uucore::parser::shortcut_value_parser::ShortcutValueParser;
|
||||||
use uucore::version_cmp::version_cmp;
|
use uucore::version_cmp::version_cmp;
|
||||||
use uucore::{format_usage, help_about, help_section, help_usage, show_error};
|
use uucore::{format_usage, help_about, help_section, help_usage, show_error};
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ path = "src/split.rs"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
clap = { workspace = true }
|
clap = { workspace = true }
|
||||||
memchr = { workspace = true }
|
memchr = { workspace = true }
|
||||||
uucore = { workspace = true, features = ["fs"] }
|
uucore = { workspace = true, features = ["fs", "parser"] }
|
||||||
thiserror = { workspace = true }
|
thiserror = { workspace = true }
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
|
|
|
@ -22,7 +22,7 @@ use std::path::Path;
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
use uucore::display::Quotable;
|
use uucore::display::Quotable;
|
||||||
use uucore::error::{FromIo, UIoError, UResult, USimpleError, UUsageError};
|
use uucore::error::{FromIo, UIoError, UResult, USimpleError, UUsageError};
|
||||||
use uucore::parse_size::parse_size_u64;
|
use uucore::parser::parse_size::parse_size_u64;
|
||||||
|
|
||||||
use uucore::uio_error;
|
use uucore::uio_error;
|
||||||
use uucore::{format_usage, help_about, help_section, help_usage};
|
use uucore::{format_usage, help_about, help_section, help_usage};
|
||||||
|
|
|
@ -10,7 +10,7 @@ use clap::{ArgMatches, parser::ValueSource};
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
use uucore::{
|
use uucore::{
|
||||||
display::Quotable,
|
display::Quotable,
|
||||||
parse_size::{ParseSizeError, parse_size_u64, parse_size_u64_max},
|
parser::parse_size::{ParseSizeError, parse_size_u64, parse_size_u64_max},
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Sub-strategy of the [`Strategy::Number`]
|
/// Sub-strategy of the [`Strategy::Number`]
|
||||||
|
|
|
@ -19,7 +19,7 @@ path = "src/stdbuf.rs"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
clap = { workspace = true }
|
clap = { workspace = true }
|
||||||
tempfile = { workspace = true }
|
tempfile = { workspace = true }
|
||||||
uucore = { workspace = true }
|
uucore = { workspace = true, features = ["parser"] }
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
libstdbuf = { version = "0.0.30", package = "uu_stdbuf_libstdbuf", path = "src/libstdbuf" }
|
libstdbuf = { version = "0.0.30", package = "uu_stdbuf_libstdbuf", path = "src/libstdbuf" }
|
||||||
|
|
|
@ -14,7 +14,7 @@ use std::process;
|
||||||
use tempfile::TempDir;
|
use tempfile::TempDir;
|
||||||
use tempfile::tempdir;
|
use tempfile::tempdir;
|
||||||
use uucore::error::{FromIo, UClapError, UResult, USimpleError, UUsageError};
|
use uucore::error::{FromIo, UClapError, UResult, USimpleError, UUsageError};
|
||||||
use uucore::parse_size::parse_size_u64;
|
use uucore::parser::parse_size::parse_size_u64;
|
||||||
use uucore::{format_usage, help_about, help_section, help_usage};
|
use uucore::{format_usage, help_about, help_section, help_usage};
|
||||||
|
|
||||||
const ABOUT: &str = help_about!("stdbuf.md");
|
const ABOUT: &str = help_about!("stdbuf.md");
|
||||||
|
|
|
@ -22,7 +22,7 @@ clap = { workspace = true }
|
||||||
libc = { workspace = true }
|
libc = { workspace = true }
|
||||||
memchr = { workspace = true }
|
memchr = { workspace = true }
|
||||||
notify = { workspace = true }
|
notify = { workspace = true }
|
||||||
uucore = { workspace = true }
|
uucore = { workspace = true, features = ["parser"] }
|
||||||
same-file = { workspace = true }
|
same-file = { workspace = true }
|
||||||
fundu = { workspace = true }
|
fundu = { workspace = true }
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,8 @@ use std::ffi::OsString;
|
||||||
use std::io::IsTerminal;
|
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::{ParseSizeError, parse_size_u64};
|
use uucore::parser::parse_size::{ParseSizeError, parse_size_u64};
|
||||||
use uucore::shortcut_value_parser::ShortcutValueParser;
|
use uucore::parser::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");
|
||||||
|
|
|
@ -19,7 +19,7 @@ path = "src/tee.rs"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
clap = { workspace = true }
|
clap = { workspace = true }
|
||||||
nix = { workspace = true, features = ["poll", "fs"] }
|
nix = { workspace = true, features = ["poll", "fs"] }
|
||||||
uucore = { workspace = true, features = ["libc", "signals"] }
|
uucore = { workspace = true, features = ["libc", "parser", "signals"] }
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "tee"
|
name = "tee"
|
||||||
|
|
|
@ -11,7 +11,7 @@ use std::io::{Error, ErrorKind, Read, Result, Write, copy, stdin, stdout};
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use uucore::display::Quotable;
|
use uucore::display::Quotable;
|
||||||
use uucore::error::UResult;
|
use uucore::error::UResult;
|
||||||
use uucore::shortcut_value_parser::ShortcutValueParser;
|
use uucore::parser::shortcut_value_parser::ShortcutValueParser;
|
||||||
use uucore::{format_usage, help_about, help_section, help_usage, show_error};
|
use uucore::{format_usage, help_about, help_section, help_usage, show_error};
|
||||||
|
|
||||||
// spell-checker:ignore nopipe
|
// spell-checker:ignore nopipe
|
||||||
|
|
|
@ -20,7 +20,7 @@ path = "src/timeout.rs"
|
||||||
clap = { workspace = true }
|
clap = { workspace = true }
|
||||||
libc = { workspace = true }
|
libc = { workspace = true }
|
||||||
nix = { workspace = true, features = ["signal"] }
|
nix = { workspace = true, features = ["signal"] }
|
||||||
uucore = { workspace = true, features = ["process", "signals"] }
|
uucore = { workspace = true, features = ["parser", "process", "signals"] }
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "timeout"
|
name = "timeout"
|
||||||
|
|
|
@ -14,6 +14,7 @@ use std::process::{self, Child, Stdio};
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use uucore::display::Quotable;
|
use uucore::display::Quotable;
|
||||||
use uucore::error::{UClapError, UResult, USimpleError, UUsageError};
|
use uucore::error::{UClapError, UResult, USimpleError, UUsageError};
|
||||||
|
use uucore::parser::parse_time;
|
||||||
use uucore::process::ChildExt;
|
use uucore::process::ChildExt;
|
||||||
|
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
|
@ -70,15 +71,14 @@ impl Config {
|
||||||
|
|
||||||
let kill_after = match options.get_one::<String>(options::KILL_AFTER) {
|
let kill_after = match options.get_one::<String>(options::KILL_AFTER) {
|
||||||
None => None,
|
None => None,
|
||||||
Some(kill_after) => match uucore::parse_time::from_str(kill_after) {
|
Some(kill_after) => match parse_time::from_str(kill_after) {
|
||||||
Ok(k) => Some(k),
|
Ok(k) => Some(k),
|
||||||
Err(err) => return Err(UUsageError::new(ExitStatus::TimeoutFailed.into(), err)),
|
Err(err) => return Err(UUsageError::new(ExitStatus::TimeoutFailed.into(), err)),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
let duration = match uucore::parse_time::from_str(
|
let duration =
|
||||||
options.get_one::<String>(options::DURATION).unwrap(),
|
match parse_time::from_str(options.get_one::<String>(options::DURATION).unwrap()) {
|
||||||
) {
|
|
||||||
Ok(duration) => duration,
|
Ok(duration) => duration,
|
||||||
Err(err) => return Err(UUsageError::new(ExitStatus::TimeoutFailed.into(), err)),
|
Err(err) => return Err(UUsageError::new(ExitStatus::TimeoutFailed.into(), err)),
|
||||||
};
|
};
|
||||||
|
|
|
@ -23,7 +23,7 @@ clap = { workspace = true }
|
||||||
chrono = { workspace = true }
|
chrono = { workspace = true }
|
||||||
parse_datetime = { workspace = true }
|
parse_datetime = { workspace = true }
|
||||||
thiserror = { workspace = true }
|
thiserror = { workspace = true }
|
||||||
uucore = { workspace = true, features = ["libc"] }
|
uucore = { workspace = true, features = ["libc", "parser"] }
|
||||||
|
|
||||||
[target.'cfg(target_os = "windows")'.dependencies]
|
[target.'cfg(target_os = "windows")'.dependencies]
|
||||||
windows-sys = { workspace = true, features = [
|
windows-sys = { workspace = true, features = [
|
||||||
|
|
|
@ -22,7 +22,7 @@ use std::io::{Error, ErrorKind};
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use uucore::display::Quotable;
|
use uucore::display::Quotable;
|
||||||
use uucore::error::{FromIo, UResult, USimpleError};
|
use uucore::error::{FromIo, UResult, USimpleError};
|
||||||
use uucore::shortcut_value_parser::ShortcutValueParser;
|
use uucore::parser::shortcut_value_parser::ShortcutValueParser;
|
||||||
use uucore::{format_usage, help_about, help_usage, show};
|
use uucore::{format_usage, help_about, help_usage, show};
|
||||||
|
|
||||||
use crate::error::TouchError;
|
use crate::error::TouchError;
|
||||||
|
|
|
@ -18,7 +18,7 @@ path = "src/truncate.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
clap = { workspace = true }
|
clap = { workspace = true }
|
||||||
uucore = { workspace = true }
|
uucore = { workspace = true, features = ["parser"] }
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "truncate"
|
name = "truncate"
|
||||||
|
|
|
@ -12,7 +12,7 @@ use std::os::unix::fs::FileTypeExt;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use uucore::display::Quotable;
|
use uucore::display::Quotable;
|
||||||
use uucore::error::{FromIo, UResult, USimpleError, UUsageError};
|
use uucore::error::{FromIo, UResult, USimpleError, UUsageError};
|
||||||
use uucore::parse_size::{ParseSizeError, parse_size_u64};
|
use uucore::parser::parse_size::{ParseSizeError, parse_size_u64};
|
||||||
use uucore::{format_usage, help_about, help_section, help_usage};
|
use uucore::{format_usage, help_about, help_section, help_usage};
|
||||||
|
|
||||||
#[derive(Debug, Eq, PartialEq)]
|
#[derive(Debug, Eq, PartialEq)]
|
||||||
|
|
|
@ -18,7 +18,7 @@ path = "src/uniq.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
clap = { workspace = true }
|
clap = { workspace = true }
|
||||||
uucore = { workspace = true }
|
uucore = { workspace = true, features = ["parser"] }
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "uniq"
|
name = "uniq"
|
||||||
|
|
|
@ -13,8 +13,8 @@ use std::io::{BufRead, BufReader, BufWriter, Write, stdin, stdout};
|
||||||
use std::num::IntErrorKind;
|
use std::num::IntErrorKind;
|
||||||
use uucore::display::Quotable;
|
use uucore::display::Quotable;
|
||||||
use uucore::error::{FromIo, UError, UResult, USimpleError};
|
use uucore::error::{FromIo, UError, UResult, USimpleError};
|
||||||
|
use uucore::parser::shortcut_value_parser::ShortcutValueParser;
|
||||||
use uucore::posix::{OBSOLETE, posix_version};
|
use uucore::posix::{OBSOLETE, posix_version};
|
||||||
use uucore::shortcut_value_parser::ShortcutValueParser;
|
|
||||||
use uucore::{format_usage, help_about, help_section, help_usage};
|
use uucore::{format_usage, help_about, help_section, help_usage};
|
||||||
|
|
||||||
const ABOUT: &str = help_about!("uniq.md");
|
const ABOUT: &str = help_about!("uniq.md");
|
||||||
|
|
|
@ -18,7 +18,7 @@ path = "src/wc.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
clap = { workspace = true }
|
clap = { workspace = true }
|
||||||
uucore = { workspace = true, features = ["pipes", "quoting-style"] }
|
uucore = { workspace = true, features = ["parser", "pipes", "quoting-style"] }
|
||||||
bytecount = { workspace = true, features = ["runtime-dispatch-simd"] }
|
bytecount = { workspace = true, features = ["runtime-dispatch-simd"] }
|
||||||
thiserror = { workspace = true }
|
thiserror = { workspace = true }
|
||||||
unicode-width = { workspace = true }
|
unicode-width = { workspace = true }
|
||||||
|
|
|
@ -28,8 +28,8 @@ use utf8::{BufReadDecoder, BufReadDecoderError};
|
||||||
use uucore::{
|
use uucore::{
|
||||||
error::{FromIo, UError, UResult},
|
error::{FromIo, UError, UResult},
|
||||||
format_usage, help_about, help_usage,
|
format_usage, help_about, help_usage,
|
||||||
|
parser::shortcut_value_parser::ShortcutValueParser,
|
||||||
quoting_style::{self, QuotingStyle},
|
quoting_style::{self, QuotingStyle},
|
||||||
shortcut_value_parser::ShortcutValueParser,
|
|
||||||
show,
|
show,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -101,6 +101,7 @@ format = [
|
||||||
"bigdecimal",
|
"bigdecimal",
|
||||||
"extendedbigdecimal",
|
"extendedbigdecimal",
|
||||||
"itertools",
|
"itertools",
|
||||||
|
"parser",
|
||||||
"num-traits",
|
"num-traits",
|
||||||
"quoting-style",
|
"quoting-style",
|
||||||
]
|
]
|
||||||
|
@ -113,6 +114,7 @@ proc-info = ["tty", "walkdir"]
|
||||||
quoting-style = []
|
quoting-style = []
|
||||||
ranges = []
|
ranges = []
|
||||||
ringbuffer = []
|
ringbuffer = []
|
||||||
|
parser = ["extendedbigdecimal", "num-traits"]
|
||||||
signals = []
|
signals = []
|
||||||
sum = [
|
sum = [
|
||||||
"digest",
|
"digest",
|
||||||
|
@ -127,7 +129,7 @@ sum = [
|
||||||
"sm3",
|
"sm3",
|
||||||
"crc32fast",
|
"crc32fast",
|
||||||
]
|
]
|
||||||
update-control = []
|
update-control = ["parser"]
|
||||||
utf8 = []
|
utf8 = []
|
||||||
utmpx = ["time", "time/macros", "libc", "dns-lookup"]
|
utmpx = ["time", "time/macros", "libc", "dns-lookup"]
|
||||||
version-cmp = []
|
version-cmp = []
|
||||||
|
|
|
@ -28,6 +28,8 @@ pub mod fs;
|
||||||
pub mod fsext;
|
pub mod fsext;
|
||||||
#[cfg(feature = "lines")]
|
#[cfg(feature = "lines")]
|
||||||
pub mod lines;
|
pub mod lines;
|
||||||
|
#[cfg(feature = "parser")]
|
||||||
|
pub mod parser;
|
||||||
#[cfg(feature = "quoting-style")]
|
#[cfg(feature = "quoting-style")]
|
||||||
pub mod quoting_style;
|
pub mod quoting_style;
|
||||||
#[cfg(feature = "ranges")]
|
#[cfg(feature = "ranges")]
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
error::set_exit_code,
|
error::set_exit_code,
|
||||||
features::format::num_parser::{ExtendedParser, ExtendedParserError},
|
parser::num_parser::{ExtendedParser, ExtendedParserError},
|
||||||
quoting_style::{Quotes, QuotingStyle, escape_name},
|
quoting_style::{Quotes, QuotingStyle, escape_name},
|
||||||
show_error, show_warning,
|
show_error, show_warning,
|
||||||
};
|
};
|
||||||
|
|
|
@ -35,7 +35,6 @@ mod argument;
|
||||||
mod escape;
|
mod escape;
|
||||||
pub mod human;
|
pub mod human;
|
||||||
pub mod num_format;
|
pub mod num_format;
|
||||||
pub mod num_parser;
|
|
||||||
mod spec;
|
mod spec;
|
||||||
|
|
||||||
use crate::extendedbigdecimal::ExtendedBigDecimal;
|
use crate::extendedbigdecimal::ExtendedBigDecimal;
|
||||||
|
|
|
@ -2,6 +2,9 @@
|
||||||
//
|
//
|
||||||
// For the full copyright and license information, please view the LICENSE
|
// For the full copyright and license information, please view the LICENSE
|
||||||
// file that was distributed with this source code.
|
// file that was distributed with this source code.
|
||||||
|
// spell-checker:ignore extendedbigdecimal
|
||||||
|
|
||||||
|
pub mod num_parser;
|
||||||
pub mod parse_glob;
|
pub mod parse_glob;
|
||||||
pub mod parse_size;
|
pub mod parse_size;
|
||||||
pub mod parse_time;
|
pub mod parse_time;
|
|
@ -48,7 +48,7 @@ fn fix_negation(glob: &str) -> String {
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// use std::time::Duration;
|
/// use std::time::Duration;
|
||||||
/// use uucore::parse_glob::from_str;
|
/// use uucore::parser::parse_glob::from_str;
|
||||||
/// assert!(!from_str("[^abc]").unwrap().matches("a"));
|
/// assert!(!from_str("[^abc]").unwrap().matches("a"));
|
||||||
/// assert!(from_str("[^abc]").unwrap().matches("x"));
|
/// assert!(from_str("[^abc]").unwrap().matches("x"));
|
||||||
/// ```
|
/// ```
|
|
@ -136,7 +136,7 @@ impl<'parser> Parser<'parser> {
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// use uucore::parse_size::Parser;
|
/// use uucore::parser::parse_size::Parser;
|
||||||
/// let parser = Parser {
|
/// let parser = Parser {
|
||||||
/// default_unit: Some("M"),
|
/// default_unit: Some("M"),
|
||||||
/// ..Default::default()
|
/// ..Default::default()
|
||||||
|
@ -346,7 +346,7 @@ impl<'parser> Parser<'parser> {
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// use uucore::parse_size::parse_size_u128;
|
/// use uucore::parser::parse_size::parse_size_u128;
|
||||||
/// assert_eq!(Ok(123), parse_size_u128("123"));
|
/// assert_eq!(Ok(123), parse_size_u128("123"));
|
||||||
/// assert_eq!(Ok(9 * 1000), parse_size_u128("9kB")); // kB is 1000
|
/// assert_eq!(Ok(9 * 1000), parse_size_u128("9kB")); // kB is 1000
|
||||||
/// assert_eq!(Ok(2 * 1024), parse_size_u128("2K")); // K is 1024
|
/// assert_eq!(Ok(2 * 1024), parse_size_u128("2K")); // K is 1024
|
|
@ -40,7 +40,7 @@ use crate::display::Quotable;
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// use std::time::Duration;
|
/// use std::time::Duration;
|
||||||
/// use uucore::parse_time::from_str;
|
/// use uucore::parser::parse_time::from_str;
|
||||||
/// assert_eq!(from_str("123"), Ok(Duration::from_secs(123)));
|
/// assert_eq!(from_str("123"), Ok(Duration::from_secs(123)));
|
||||||
/// assert_eq!(from_str("2d"), Ok(Duration::from_secs(60 * 60 * 24 * 2)));
|
/// assert_eq!(from_str("2d"), Ok(Duration::from_secs(60 * 60 * 24 * 2)));
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -84,7 +84,7 @@ pub fn from_str(string: &str) -> Result<Duration, String> {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
|
||||||
use crate::parse_time::from_str;
|
use crate::parser::parse_time::from_str;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
|
@ -65,7 +65,7 @@ pub enum UpdateMode {
|
||||||
|
|
||||||
pub mod arguments {
|
pub mod arguments {
|
||||||
//! Pre-defined arguments for update functionality.
|
//! Pre-defined arguments for update functionality.
|
||||||
use crate::shortcut_value_parser::ShortcutValueParser;
|
use crate::parser::shortcut_value_parser::ShortcutValueParser;
|
||||||
use clap::ArgAction;
|
use clap::ArgAction;
|
||||||
|
|
||||||
/// `--update` argument
|
/// `--update` argument
|
||||||
|
|
|
@ -18,7 +18,6 @@ pub extern crate windows_sys;
|
||||||
mod features; // feature-gated code modules
|
mod features; // feature-gated code modules
|
||||||
mod macros; // crate macros (macro_rules-type; exported to `crate::...`)
|
mod macros; // crate macros (macro_rules-type; exported to `crate::...`)
|
||||||
mod mods; // core cross-platform modules
|
mod mods; // core cross-platform modules
|
||||||
mod parser; // string parsing modules
|
|
||||||
|
|
||||||
pub use uucore_procs::*;
|
pub use uucore_procs::*;
|
||||||
|
|
||||||
|
@ -31,12 +30,6 @@ pub use crate::mods::os;
|
||||||
pub use crate::mods::panic;
|
pub use crate::mods::panic;
|
||||||
pub use crate::mods::posix;
|
pub use crate::mods::posix;
|
||||||
|
|
||||||
// * string parsing modules
|
|
||||||
pub use crate::parser::parse_glob;
|
|
||||||
pub use crate::parser::parse_size;
|
|
||||||
pub use crate::parser::parse_time;
|
|
||||||
pub use crate::parser::shortcut_value_parser;
|
|
||||||
|
|
||||||
// * feature-gated modules
|
// * feature-gated modules
|
||||||
#[cfg(feature = "backup-control")]
|
#[cfg(feature = "backup-control")]
|
||||||
pub use crate::features::backup_control;
|
pub use crate::features::backup_control;
|
||||||
|
@ -58,6 +51,8 @@ pub use crate::features::format;
|
||||||
pub use crate::features::fs;
|
pub use crate::features::fs;
|
||||||
#[cfg(feature = "lines")]
|
#[cfg(feature = "lines")]
|
||||||
pub use crate::features::lines;
|
pub use crate::features::lines;
|
||||||
|
#[cfg(feature = "parser")]
|
||||||
|
pub use crate::features::parser;
|
||||||
#[cfg(feature = "quoting-style")]
|
#[cfg(feature = "quoting-style")]
|
||||||
pub use crate::features::quoting_style;
|
pub use crate::features::quoting_style;
|
||||||
#[cfg(feature = "ranges")]
|
#[cfg(feature = "ranges")]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue