diff --git a/fuzz/Cargo.toml b/fuzz/Cargo.toml index 4f16408dd..255d11d5b 100644 --- a/fuzz/Cargo.toml +++ b/fuzz/Cargo.toml @@ -15,7 +15,7 @@ tempfile = "3.15.0" rand = { version = "0.9.0", features = ["small_rng"] } similar = "2.5.0" -uucore = { path = "../src/uucore/" } +uucore = { path = "../src/uucore/", features = ["parser"] } uu_date = { path = "../src/uu/date/" } uu_test = { path = "../src/uu/test/" } uu_expr = { path = "../src/uu/expr/" } diff --git a/fuzz/fuzz_targets/fuzz_parse_glob.rs b/fuzz/fuzz_targets/fuzz_parse_glob.rs index e235c0c9d..66e772959 100644 --- a/fuzz/fuzz_targets/fuzz_parse_glob.rs +++ b/fuzz/fuzz_targets/fuzz_parse_glob.rs @@ -1,7 +1,7 @@ #![no_main] use libfuzzer_sys::fuzz_target; -use uucore::parse_glob; +use uucore::parser::parse_glob; fuzz_target!(|data: &[u8]| { if let Ok(s) = std::str::from_utf8(data) { diff --git a/fuzz/fuzz_targets/fuzz_parse_size.rs b/fuzz/fuzz_targets/fuzz_parse_size.rs index d032adf06..4e8d7e221 100644 --- a/fuzz/fuzz_targets/fuzz_parse_size.rs +++ b/fuzz/fuzz_targets/fuzz_parse_size.rs @@ -1,7 +1,7 @@ #![no_main] use libfuzzer_sys::fuzz_target; -use uucore::parse_size::parse_size_u64; +use uucore::parser::parse_size::parse_size_u64; fuzz_target!(|data: &[u8]| { if let Ok(s) = std::str::from_utf8(data) { diff --git a/fuzz/fuzz_targets/fuzz_parse_time.rs b/fuzz/fuzz_targets/fuzz_parse_time.rs index a643c6d80..3aff82dc7 100644 --- a/fuzz/fuzz_targets/fuzz_parse_time.rs +++ b/fuzz/fuzz_targets/fuzz_parse_time.rs @@ -1,7 +1,7 @@ #![no_main] use libfuzzer_sys::fuzz_target; -use uucore::parse_time; +use uucore::parser::parse_time; fuzz_target!(|data: &[u8]| { if let Ok(s) = std::str::from_utf8(data) { diff --git a/src/uu/cp/Cargo.toml b/src/uu/cp/Cargo.toml index 2cb2df9e7..a6bab6ea8 100644 --- a/src/uu/cp/Cargo.toml +++ b/src/uu/cp/Cargo.toml @@ -33,6 +33,7 @@ uucore = { workspace = true, features = [ "entries", "fs", "fsxattr", + "parser", "perms", "mode", "update-control", diff --git a/src/uu/cp/src/cp.rs b/src/uu/cp/src/cp.rs index 356220f7d..d46b13396 100644 --- a/src/uu/cp/src/cp.rs +++ b/src/uu/cp/src/cp.rs @@ -40,8 +40,8 @@ use uucore::{backup_control, update_control}; // requires these enum. pub use uucore::{backup_control::BackupMode, update_control::UpdateMode}; use uucore::{ - format_usage, help_about, help_section, help_usage, prompt_yes, - shortcut_value_parser::ShortcutValueParser, show_error, show_warning, + format_usage, help_about, help_section, help_usage, + parser::shortcut_value_parser::ShortcutValueParser, prompt_yes, show_error, show_warning, }; use crate::copydir::copy_directory; diff --git a/src/uu/date/Cargo.toml b/src/uu/date/Cargo.toml index cb5fbbf8c..f9d96c605 100644 --- a/src/uu/date/Cargo.toml +++ b/src/uu/date/Cargo.toml @@ -20,7 +20,7 @@ path = "src/date.rs" [dependencies] chrono = { workspace = true } clap = { workspace = true } -uucore = { workspace = true, features = ["custom-tz-fmt"] } +uucore = { workspace = true, features = ["custom-tz-fmt", "parser"] } parse_datetime = { workspace = true } [target.'cfg(unix)'.dependencies] diff --git a/src/uu/date/src/date.rs b/src/uu/date/src/date.rs index f1e45561f..c305e2548 100644 --- a/src/uu/date/src/date.rs +++ b/src/uu/date/src/date.rs @@ -23,7 +23,7 @@ use uucore::{format_usage, help_about, help_usage, show}; #[cfg(windows)] use windows_sys::Win32::{Foundation::SYSTEMTIME, System::SystemInformation::SetSystemTime}; -use uucore::shortcut_value_parser::ShortcutValueParser; +use uucore::parser::shortcut_value_parser::ShortcutValueParser; // Options const DATE: &str = "date"; diff --git a/src/uu/dd/Cargo.toml b/src/uu/dd/Cargo.toml index 7ad694778..9a34631f2 100644 --- a/src/uu/dd/Cargo.toml +++ b/src/uu/dd/Cargo.toml @@ -20,7 +20,7 @@ path = "src/dd.rs" clap = { workspace = true } gcd = { workspace = true } libc = { workspace = true } -uucore = { workspace = true, features = ["format", "quoting-style"] } +uucore = { workspace = true, features = ["format", "parser", "quoting-style"] } thiserror = { workspace = true } [target.'cfg(any(target_os = "linux", target_os = "android"))'.dependencies] diff --git a/src/uu/dd/src/parseargs.rs b/src/uu/dd/src/parseargs.rs index 32242004d..8d75e2a2a 100644 --- a/src/uu/dd/src/parseargs.rs +++ b/src/uu/dd/src/parseargs.rs @@ -12,7 +12,7 @@ use crate::conversion_tables::ConversionTable; use thiserror::Error; use uucore::display::Quotable; 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; /// Parser Errors describe errors with parser input diff --git a/src/uu/df/Cargo.toml b/src/uu/df/Cargo.toml index 8e2560854..61a7e8377 100644 --- a/src/uu/df/Cargo.toml +++ b/src/uu/df/Cargo.toml @@ -18,7 +18,7 @@ path = "src/df.rs" [dependencies] clap = { workspace = true } -uucore = { workspace = true, features = ["libc", "fsext"] } +uucore = { workspace = true, features = ["libc", "fsext", "parser"] } unicode-width = { workspace = true } thiserror = { workspace = true } diff --git a/src/uu/df/src/blocks.rs b/src/uu/df/src/blocks.rs index c5493cfd2..82f0d4bd5 100644 --- a/src/uu/df/src/blocks.rs +++ b/src/uu/df/src/blocks.rs @@ -9,7 +9,7 @@ use std::{env, fmt}; use uucore::{ display::Quotable, - parse_size::{ParseSizeError, parse_size_u64}, + parser::parse_size::{ParseSizeError, parse_size_u64}, }; /// The first ten powers of 1024. diff --git a/src/uu/df/src/df.rs b/src/uu/df/src/df.rs index 04bb99a49..517673b7b 100644 --- a/src/uu/df/src/df.rs +++ b/src/uu/df/src/df.rs @@ -14,7 +14,7 @@ use table::HeaderMode; use uucore::display::Quotable; use uucore::error::{UError, UResult, USimpleError}; 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 clap::{Arg, ArgAction, ArgMatches, Command, parser::ValueSource}; diff --git a/src/uu/dircolors/Cargo.toml b/src/uu/dircolors/Cargo.toml index 380259fa7..ffa0ade1f 100644 --- a/src/uu/dircolors/Cargo.toml +++ b/src/uu/dircolors/Cargo.toml @@ -18,7 +18,7 @@ path = "src/dircolors.rs" [dependencies] clap = { workspace = true } -uucore = { workspace = true, features = ["colors"] } +uucore = { workspace = true, features = ["colors", "parser"] } [[bin]] name = "dircolors" diff --git a/src/uu/dircolors/src/dircolors.rs b/src/uu/dircolors/src/dircolors.rs index 457df666e..108049129 100644 --- a/src/uu/dircolors/src/dircolors.rs +++ b/src/uu/dircolors/src/dircolors.rs @@ -15,7 +15,7 @@ use clap::{Arg, ArgAction, Command}; use uucore::colors::{FILE_ATTRIBUTE_CODES, FILE_COLORS, FILE_TYPES, TERMS}; use uucore::display::Quotable; 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 { pub const BOURNE_SHELL: &str = "bourne-shell"; diff --git a/src/uu/du/Cargo.toml b/src/uu/du/Cargo.toml index 6494054a6..5bceda4b1 100644 --- a/src/uu/du/Cargo.toml +++ b/src/uu/du/Cargo.toml @@ -21,7 +21,7 @@ chrono = { workspace = true } # For the --exclude & --exclude-from options glob = { workspace = true } clap = { workspace = true } -uucore = { workspace = true, features = ["format"] } +uucore = { workspace = true, features = ["format", "parser"] } thiserror = { workspace = true } [target.'cfg(target_os = "windows")'.dependencies] diff --git a/src/uu/du/src/du.rs b/src/uu/du/src/du.rs index d87383db2..af5205435 100644 --- a/src/uu/du/src/du.rs +++ b/src/uu/du/src/du.rs @@ -27,9 +27,9 @@ use thiserror::Error; use uucore::display::{Quotable, print_verbatim}; use uucore::error::{FromIo, UError, UResult, USimpleError, set_exit_code}; use uucore::line_ending::LineEnding; -use uucore::parse_glob; -use uucore::parse_size::{ParseSizeError, parse_size_u64}; -use uucore::shortcut_value_parser::ShortcutValueParser; +use uucore::parser::parse_glob; +use uucore::parser::parse_size::{ParseSizeError, parse_size_u64}; +use uucore::parser::shortcut_value_parser::ShortcutValueParser; use uucore::{format_usage, help_about, help_section, help_usage, show, show_error, show_warning}; #[cfg(windows)] use windows_sys::Win32::Foundation::HANDLE; diff --git a/src/uu/head/Cargo.toml b/src/uu/head/Cargo.toml index da3b69ecc..d1fc4bc15 100644 --- a/src/uu/head/Cargo.toml +++ b/src/uu/head/Cargo.toml @@ -20,7 +20,12 @@ path = "src/head.rs" clap = { workspace = true } memchr = { workspace = true } thiserror = { workspace = true } -uucore = { workspace = true, features = ["ringbuffer", "lines", "fs"] } +uucore = { workspace = true, features = [ + "parser", + "ringbuffer", + "lines", + "fs", +] } [[bin]] name = "head" diff --git a/src/uu/head/src/parse.rs b/src/uu/head/src/parse.rs index c2729ca89..097599bc2 100644 --- a/src/uu/head/src/parse.rs +++ b/src/uu/head/src/parse.rs @@ -4,7 +4,7 @@ // file that was distributed with this source code. 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)] pub enum ParseError { diff --git a/src/uu/ls/Cargo.toml b/src/uu/ls/Cargo.toml index 00963e269..e8f9a14ec 100644 --- a/src/uu/ls/Cargo.toml +++ b/src/uu/ls/Cargo.toml @@ -34,6 +34,7 @@ uucore = { workspace = true, features = [ "format", "fs", "fsxattr", + "parser", "quoting-style", "version-cmp", ] } diff --git a/src/uu/ls/src/ls.rs b/src/uu/ls/src/ls.rs index 21aecfd27..e293580ed 100644 --- a/src/uu/ls/src/ls.rs +++ b/src/uu/ls/src/ls.rs @@ -63,11 +63,13 @@ use uucore::{ format_usage, fs::display_permissions, os_str_as_bytes_lossy, - parse_size::parse_size_u64, - shortcut_value_parser::ShortcutValueParser, + parser::parse_size::parse_size_u64, + parser::shortcut_value_parser::ShortcutValueParser, 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; use dired::{DiredOutput, is_dired_arg_present}; diff --git a/src/uu/numfmt/Cargo.toml b/src/uu/numfmt/Cargo.toml index 0bad48915..0b121f1f6 100644 --- a/src/uu/numfmt/Cargo.toml +++ b/src/uu/numfmt/Cargo.toml @@ -18,7 +18,7 @@ path = "src/numfmt.rs" [dependencies] clap = { workspace = true } -uucore = { workspace = true, features = ["ranges"] } +uucore = { workspace = true, features = ["parser", "ranges"] } thiserror = { workspace = true } [[bin]] diff --git a/src/uu/numfmt/src/numfmt.rs b/src/uu/numfmt/src/numfmt.rs index 903f39a10..b024e99b7 100644 --- a/src/uu/numfmt/src/numfmt.rs +++ b/src/uu/numfmt/src/numfmt.rs @@ -14,8 +14,8 @@ use std::str::FromStr; use units::{IEC_BASES, SI_BASES}; use uucore::display::Quotable; use uucore::error::UResult; +use uucore::parser::shortcut_value_parser::ShortcutValueParser; use uucore::ranges::Range; -use uucore::shortcut_value_parser::ShortcutValueParser; use uucore::{format_usage, help_about, help_section, help_usage, show, show_error}; pub mod errors; diff --git a/src/uu/od/Cargo.toml b/src/uu/od/Cargo.toml index 21942ae15..dcae75171 100644 --- a/src/uu/od/Cargo.toml +++ b/src/uu/od/Cargo.toml @@ -20,7 +20,7 @@ path = "src/od.rs" byteorder = { workspace = true } clap = { workspace = true } half = { workspace = true } -uucore = { workspace = true } +uucore = { workspace = true, features = ["parser"] } [[bin]] name = "od" diff --git a/src/uu/od/src/od.rs b/src/uu/od/src/od.rs index e92452d60..818815d34 100644 --- a/src/uu/od/src/od.rs +++ b/src/uu/od/src/od.rs @@ -43,8 +43,8 @@ use clap::ArgAction; use clap::{Arg, ArgMatches, Command, parser::ValueSource}; use uucore::display::Quotable; use uucore::error::{UResult, USimpleError}; -use uucore::parse_size::ParseSizeError; -use uucore::shortcut_value_parser::ShortcutValueParser; +use uucore::parser::parse_size::ParseSizeError; +use uucore::parser::shortcut_value_parser::ShortcutValueParser; 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 diff --git a/src/uu/od/src/parse_nrofbytes.rs b/src/uu/od/src/parse_nrofbytes.rs index d4aabad26..241e1c6e7 100644 --- a/src/uu/od/src/parse_nrofbytes.rs +++ b/src/uu/od/src/parse_nrofbytes.rs @@ -2,7 +2,7 @@ // // For the full copyright and license information, please view the LICENSE // 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 { let mut start = 0; diff --git a/src/uu/seq/Cargo.toml b/src/uu/seq/Cargo.toml index 554deab4b..f90c039cd 100644 --- a/src/uu/seq/Cargo.toml +++ b/src/uu/seq/Cargo.toml @@ -1,4 +1,4 @@ -# spell-checker:ignore bigdecimal cfgs +# spell-checker:ignore bigdecimal cfgs extendedbigdecimal [package] name = "uu_seq" version = "0.0.30" @@ -23,7 +23,12 @@ clap = { workspace = true } num-bigint = { workspace = true } num-traits = { workspace = true } thiserror = { workspace = true } -uucore = { workspace = true, features = ["format", "quoting-style"] } +uucore = { workspace = true, features = [ + "extendedbigdecimal", + "format", + "parser", + "quoting-style", +] } [[bin]] name = "seq" diff --git a/src/uu/seq/src/number.rs b/src/uu/seq/src/number.rs index b70ba446e..f23e42b1c 100644 --- a/src/uu/seq/src/number.rs +++ b/src/uu/seq/src/number.rs @@ -5,7 +5,7 @@ // spell-checker:ignore extendedbigdecimal use num_traits::Zero; -use uucore::format::ExtendedBigDecimal; +use uucore::extendedbigdecimal::ExtendedBigDecimal; /// A number with a specified number of integer and fractional digits. /// diff --git a/src/uu/seq/src/numberparse.rs b/src/uu/seq/src/numberparse.rs index 11a9df076..7e6d3adc8 100644 --- a/src/uu/seq/src/numberparse.rs +++ b/src/uu/seq/src/numberparse.rs @@ -9,10 +9,10 @@ //! [`PreciseNumber`] struct. use std::str::FromStr; -use uucore::format::num_parser::{ExtendedParser, ExtendedParserError}; +use uucore::parser::num_parser::{ExtendedParser, ExtendedParserError}; use crate::number::PreciseNumber; -use uucore::format::ExtendedBigDecimal; +use uucore::extendedbigdecimal::ExtendedBigDecimal; /// An error returned when parsing a number fails. #[derive(Debug, PartialEq, Eq)] @@ -126,7 +126,7 @@ impl FromStr for PreciseNumber { #[cfg(test)] mod tests { use bigdecimal::BigDecimal; - use uucore::format::ExtendedBigDecimal; + use uucore::extendedbigdecimal::ExtendedBigDecimal; use crate::number::PreciseNumber; use crate::numberparse::ParseNumberError; diff --git a/src/uu/seq/src/seq.rs b/src/uu/seq/src/seq.rs index b51df9802..27336c59f 100644 --- a/src/uu/seq/src/seq.rs +++ b/src/uu/seq/src/seq.rs @@ -10,8 +10,9 @@ use clap::{Arg, ArgAction, Command}; use num_traits::Zero; use uucore::error::{FromIo, UResult}; +use uucore::extendedbigdecimal::ExtendedBigDecimal; use uucore::format::num_format::FloatVariant; -use uucore::format::{ExtendedBigDecimal, Format, num_format}; +use uucore::format::{Format, num_format}; use uucore::{format_usage, help_about, help_usage}; mod error; diff --git a/src/uu/shred/Cargo.toml b/src/uu/shred/Cargo.toml index 3bc25dac1..e8e901a29 100644 --- a/src/uu/shred/Cargo.toml +++ b/src/uu/shred/Cargo.toml @@ -19,7 +19,7 @@ path = "src/shred.rs" [dependencies] clap = { workspace = true } rand = { workspace = true } -uucore = { workspace = true } +uucore = { workspace = true, features = ["parser"] } libc = { workspace = true } [[bin]] diff --git a/src/uu/shred/src/shred.rs b/src/uu/shred/src/shred.rs index d45a2b7b3..d62f25dd4 100644 --- a/src/uu/shred/src/shred.rs +++ b/src/uu/shred/src/shred.rs @@ -16,8 +16,8 @@ use std::os::unix::prelude::PermissionsExt; use std::path::{Path, PathBuf}; use uucore::display::Quotable; use uucore::error::{FromIo, UResult, USimpleError, UUsageError}; -use uucore::parse_size::parse_size_u64; -use uucore::shortcut_value_parser::ShortcutValueParser; +use uucore::parser::parse_size::parse_size_u64; +use uucore::parser::shortcut_value_parser::ShortcutValueParser; use uucore::{format_usage, help_about, help_section, help_usage, show_error, show_if_err}; const ABOUT: &str = help_about!("shred.md"); diff --git a/src/uu/sort/Cargo.toml b/src/uu/sort/Cargo.toml index 71a52b15c..4e87db3df 100644 --- a/src/uu/sort/Cargo.toml +++ b/src/uu/sort/Cargo.toml @@ -30,7 +30,7 @@ self_cell = { workspace = true } tempfile = { workspace = true } thiserror = { 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] nix = { workspace = true } diff --git a/src/uu/sort/src/sort.rs b/src/uu/sort/src/sort.rs index 87b0fa7b5..61cce7830 100644 --- a/src/uu/sort/src/sort.rs +++ b/src/uu/sort/src/sort.rs @@ -45,8 +45,8 @@ use uucore::display::Quotable; use uucore::error::strip_errno; use uucore::error::{UError, UResult, USimpleError, UUsageError, set_exit_code}; use uucore::line_ending::LineEnding; -use uucore::parse_size::{ParseSizeError, Parser}; -use uucore::shortcut_value_parser::ShortcutValueParser; +use uucore::parser::parse_size::{ParseSizeError, Parser}; +use uucore::parser::shortcut_value_parser::ShortcutValueParser; use uucore::version_cmp::version_cmp; use uucore::{format_usage, help_about, help_section, help_usage, show_error}; diff --git a/src/uu/split/Cargo.toml b/src/uu/split/Cargo.toml index 47b200bca..1bcfcb0c1 100644 --- a/src/uu/split/Cargo.toml +++ b/src/uu/split/Cargo.toml @@ -19,7 +19,7 @@ path = "src/split.rs" [dependencies] clap = { workspace = true } memchr = { workspace = true } -uucore = { workspace = true, features = ["fs"] } +uucore = { workspace = true, features = ["fs", "parser"] } thiserror = { workspace = true } [[bin]] diff --git a/src/uu/split/src/split.rs b/src/uu/split/src/split.rs index e7321d533..9a69d3173 100644 --- a/src/uu/split/src/split.rs +++ b/src/uu/split/src/split.rs @@ -22,7 +22,7 @@ use std::path::Path; use thiserror::Error; use uucore::display::Quotable; 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::{format_usage, help_about, help_section, help_usage}; diff --git a/src/uu/split/src/strategy.rs b/src/uu/split/src/strategy.rs index 7c0d182a1..be02de734 100644 --- a/src/uu/split/src/strategy.rs +++ b/src/uu/split/src/strategy.rs @@ -10,7 +10,7 @@ use clap::{ArgMatches, parser::ValueSource}; use thiserror::Error; use uucore::{ 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`] diff --git a/src/uu/stdbuf/Cargo.toml b/src/uu/stdbuf/Cargo.toml index 604909363..b0e229c76 100644 --- a/src/uu/stdbuf/Cargo.toml +++ b/src/uu/stdbuf/Cargo.toml @@ -19,7 +19,7 @@ path = "src/stdbuf.rs" [dependencies] clap = { workspace = true } tempfile = { workspace = true } -uucore = { workspace = true } +uucore = { workspace = true, features = ["parser"] } [build-dependencies] libstdbuf = { version = "0.0.30", package = "uu_stdbuf_libstdbuf", path = "src/libstdbuf" } diff --git a/src/uu/stdbuf/src/stdbuf.rs b/src/uu/stdbuf/src/stdbuf.rs index 93d524dbd..2e6a8e26a 100644 --- a/src/uu/stdbuf/src/stdbuf.rs +++ b/src/uu/stdbuf/src/stdbuf.rs @@ -14,7 +14,7 @@ use std::process; use tempfile::TempDir; use tempfile::tempdir; 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}; const ABOUT: &str = help_about!("stdbuf.md"); diff --git a/src/uu/tail/Cargo.toml b/src/uu/tail/Cargo.toml index 4040aaebe..cf2b1e308 100644 --- a/src/uu/tail/Cargo.toml +++ b/src/uu/tail/Cargo.toml @@ -22,7 +22,7 @@ clap = { workspace = true } libc = { workspace = true } memchr = { workspace = true } notify = { workspace = true } -uucore = { workspace = true } +uucore = { workspace = true, features = ["parser"] } same-file = { workspace = true } fundu = { workspace = true } diff --git a/src/uu/tail/src/args.rs b/src/uu/tail/src/args.rs index 7a7e6c790..e5ddb3aa2 100644 --- a/src/uu/tail/src/args.rs +++ b/src/uu/tail/src/args.rs @@ -14,8 +14,8 @@ use std::ffi::OsString; use std::io::IsTerminal; use std::time::Duration; use uucore::error::{UResult, USimpleError, UUsageError}; -use uucore::parse_size::{ParseSizeError, parse_size_u64}; -use uucore::shortcut_value_parser::ShortcutValueParser; +use uucore::parser::parse_size::{ParseSizeError, parse_size_u64}; +use uucore::parser::shortcut_value_parser::ShortcutValueParser; use uucore::{format_usage, help_about, help_usage, show_warning}; const ABOUT: &str = help_about!("tail.md"); diff --git a/src/uu/tee/Cargo.toml b/src/uu/tee/Cargo.toml index 6f7bc3a40..b6e52fb1a 100644 --- a/src/uu/tee/Cargo.toml +++ b/src/uu/tee/Cargo.toml @@ -19,7 +19,7 @@ path = "src/tee.rs" [dependencies] clap = { workspace = true } nix = { workspace = true, features = ["poll", "fs"] } -uucore = { workspace = true, features = ["libc", "signals"] } +uucore = { workspace = true, features = ["libc", "parser", "signals"] } [[bin]] name = "tee" diff --git a/src/uu/tee/src/tee.rs b/src/uu/tee/src/tee.rs index e2517cf73..4683582ca 100644 --- a/src/uu/tee/src/tee.rs +++ b/src/uu/tee/src/tee.rs @@ -11,7 +11,7 @@ use std::io::{Error, ErrorKind, Read, Result, Write, copy, stdin, stdout}; use std::path::PathBuf; use uucore::display::Quotable; 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}; // spell-checker:ignore nopipe diff --git a/src/uu/timeout/Cargo.toml b/src/uu/timeout/Cargo.toml index 979bcae1b..9a9e2987d 100644 --- a/src/uu/timeout/Cargo.toml +++ b/src/uu/timeout/Cargo.toml @@ -20,7 +20,7 @@ path = "src/timeout.rs" clap = { workspace = true } libc = { workspace = true } nix = { workspace = true, features = ["signal"] } -uucore = { workspace = true, features = ["process", "signals"] } +uucore = { workspace = true, features = ["parser", "process", "signals"] } [[bin]] name = "timeout" diff --git a/src/uu/timeout/src/timeout.rs b/src/uu/timeout/src/timeout.rs index e32d784e2..112ca19f4 100644 --- a/src/uu/timeout/src/timeout.rs +++ b/src/uu/timeout/src/timeout.rs @@ -14,6 +14,7 @@ use std::process::{self, Child, Stdio}; use std::time::Duration; use uucore::display::Quotable; use uucore::error::{UClapError, UResult, USimpleError, UUsageError}; +use uucore::parser::parse_time; use uucore::process::ChildExt; #[cfg(unix)] @@ -70,18 +71,17 @@ impl Config { let kill_after = match options.get_one::(options::KILL_AFTER) { 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), Err(err) => return Err(UUsageError::new(ExitStatus::TimeoutFailed.into(), err)), }, }; - let duration = match uucore::parse_time::from_str( - options.get_one::(options::DURATION).unwrap(), - ) { - Ok(duration) => duration, - Err(err) => return Err(UUsageError::new(ExitStatus::TimeoutFailed.into(), err)), - }; + let duration = + match parse_time::from_str(options.get_one::(options::DURATION).unwrap()) { + Ok(duration) => duration, + Err(err) => return Err(UUsageError::new(ExitStatus::TimeoutFailed.into(), err)), + }; let preserve_status: bool = options.get_flag(options::PRESERVE_STATUS); let foreground = options.get_flag(options::FOREGROUND); diff --git a/src/uu/touch/Cargo.toml b/src/uu/touch/Cargo.toml index f06b04559..15fdba163 100644 --- a/src/uu/touch/Cargo.toml +++ b/src/uu/touch/Cargo.toml @@ -23,7 +23,7 @@ clap = { workspace = true } chrono = { workspace = true } parse_datetime = { workspace = true } thiserror = { workspace = true } -uucore = { workspace = true, features = ["libc"] } +uucore = { workspace = true, features = ["libc", "parser"] } [target.'cfg(target_os = "windows")'.dependencies] windows-sys = { workspace = true, features = [ diff --git a/src/uu/touch/src/touch.rs b/src/uu/touch/src/touch.rs index dd155b44e..b5a7246d5 100644 --- a/src/uu/touch/src/touch.rs +++ b/src/uu/touch/src/touch.rs @@ -22,7 +22,7 @@ use std::io::{Error, ErrorKind}; use std::path::{Path, PathBuf}; use uucore::display::Quotable; 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 crate::error::TouchError; diff --git a/src/uu/truncate/Cargo.toml b/src/uu/truncate/Cargo.toml index 3535c5ede..8cd4cd1d3 100644 --- a/src/uu/truncate/Cargo.toml +++ b/src/uu/truncate/Cargo.toml @@ -18,7 +18,7 @@ path = "src/truncate.rs" [dependencies] clap = { workspace = true } -uucore = { workspace = true } +uucore = { workspace = true, features = ["parser"] } [[bin]] name = "truncate" diff --git a/src/uu/truncate/src/truncate.rs b/src/uu/truncate/src/truncate.rs index ac4cb7c3c..d43ae70ca 100644 --- a/src/uu/truncate/src/truncate.rs +++ b/src/uu/truncate/src/truncate.rs @@ -12,7 +12,7 @@ use std::os::unix::fs::FileTypeExt; use std::path::Path; use uucore::display::Quotable; 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}; #[derive(Debug, Eq, PartialEq)] diff --git a/src/uu/uniq/Cargo.toml b/src/uu/uniq/Cargo.toml index 0f239cf14..e47a2cfcb 100644 --- a/src/uu/uniq/Cargo.toml +++ b/src/uu/uniq/Cargo.toml @@ -18,7 +18,7 @@ path = "src/uniq.rs" [dependencies] clap = { workspace = true } -uucore = { workspace = true } +uucore = { workspace = true, features = ["parser"] } [[bin]] name = "uniq" diff --git a/src/uu/uniq/src/uniq.rs b/src/uu/uniq/src/uniq.rs index 744ff6d99..cf717e563 100644 --- a/src/uu/uniq/src/uniq.rs +++ b/src/uu/uniq/src/uniq.rs @@ -13,8 +13,8 @@ use std::io::{BufRead, BufReader, BufWriter, Write, stdin, stdout}; use std::num::IntErrorKind; use uucore::display::Quotable; use uucore::error::{FromIo, UError, UResult, USimpleError}; +use uucore::parser::shortcut_value_parser::ShortcutValueParser; use uucore::posix::{OBSOLETE, posix_version}; -use uucore::shortcut_value_parser::ShortcutValueParser; use uucore::{format_usage, help_about, help_section, help_usage}; const ABOUT: &str = help_about!("uniq.md"); diff --git a/src/uu/wc/Cargo.toml b/src/uu/wc/Cargo.toml index d4911add8..1e3fc7056 100644 --- a/src/uu/wc/Cargo.toml +++ b/src/uu/wc/Cargo.toml @@ -18,7 +18,7 @@ path = "src/wc.rs" [dependencies] 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"] } thiserror = { workspace = true } unicode-width = { workspace = true } diff --git a/src/uu/wc/src/wc.rs b/src/uu/wc/src/wc.rs index 0d5df7b65..b850e4656 100644 --- a/src/uu/wc/src/wc.rs +++ b/src/uu/wc/src/wc.rs @@ -28,8 +28,8 @@ use utf8::{BufReadDecoder, BufReadDecoderError}; use uucore::{ error::{FromIo, UError, UResult}, format_usage, help_about, help_usage, + parser::shortcut_value_parser::ShortcutValueParser, quoting_style::{self, QuotingStyle}, - shortcut_value_parser::ShortcutValueParser, show, }; diff --git a/src/uucore/Cargo.toml b/src/uucore/Cargo.toml index c061ca75f..67e1bd3e5 100644 --- a/src/uucore/Cargo.toml +++ b/src/uucore/Cargo.toml @@ -1,4 +1,4 @@ -# spell-checker:ignore (features) bigdecimal zerocopy +# spell-checker:ignore (features) bigdecimal zerocopy extendedbigdecimal [package] name = "uucore" @@ -92,11 +92,19 @@ colors = [] checksum = ["data-encoding", "thiserror", "sum"] encoding = ["data-encoding", "data-encoding-macro", "z85"] entries = ["libc"] +extendedbigdecimal = ["bigdecimal", "num-traits"] fs = ["dunce", "libc", "winapi-util", "windows-sys"] fsext = ["libc", "windows-sys"] fsxattr = ["xattr"] lines = [] -format = ["bigdecimal", "itertools", "num-traits", "quoting-style"] +format = [ + "bigdecimal", + "extendedbigdecimal", + "itertools", + "parser", + "num-traits", + "quoting-style", +] mode = ["libc"] perms = ["entries", "libc", "walkdir"] buf-copy = [] @@ -106,6 +114,7 @@ proc-info = ["tty", "walkdir"] quoting-style = [] ranges = [] ringbuffer = [] +parser = ["extendedbigdecimal", "num-traits"] signals = [] sum = [ "digest", @@ -120,7 +129,7 @@ sum = [ "sm3", "crc32fast", ] -update-control = [] +update-control = ["parser"] utf8 = [] utmpx = ["time", "time/macros", "libc", "dns-lookup"] version-cmp = [] diff --git a/src/uucore/src/lib/features.rs b/src/uucore/src/lib/features.rs index 64adb78d2..d3a8ebb44 100644 --- a/src/uucore/src/lib/features.rs +++ b/src/uucore/src/lib/features.rs @@ -3,6 +3,8 @@ // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. // features ~ feature-gated modules (core/bundler file) +// +// spell-checker:ignore (features) extendedbigdecimal #[cfg(feature = "backup-control")] pub mod backup_control; @@ -16,6 +18,8 @@ pub mod colors; pub mod custom_tz_fmt; #[cfg(feature = "encoding")] pub mod encoding; +#[cfg(feature = "extendedbigdecimal")] +pub mod extendedbigdecimal; #[cfg(feature = "format")] pub mod format; #[cfg(feature = "fs")] @@ -24,6 +28,8 @@ pub mod fs; pub mod fsext; #[cfg(feature = "lines")] pub mod lines; +#[cfg(feature = "parser")] +pub mod parser; #[cfg(feature = "quoting-style")] pub mod quoting_style; #[cfg(feature = "ranges")] diff --git a/src/uucore/src/lib/features/format/extendedbigdecimal.rs b/src/uucore/src/lib/features/extendedbigdecimal.rs similarity index 99% rename from src/uucore/src/lib/features/format/extendedbigdecimal.rs rename to src/uucore/src/lib/features/extendedbigdecimal.rs index 07c8b4621..a023a69d8 100644 --- a/src/uucore/src/lib/features/format/extendedbigdecimal.rs +++ b/src/uucore/src/lib/features/extendedbigdecimal.rs @@ -235,7 +235,7 @@ mod tests { use bigdecimal::BigDecimal; use num_traits::Zero; - use crate::format::extendedbigdecimal::ExtendedBigDecimal; + use crate::extendedbigdecimal::ExtendedBigDecimal; #[test] fn test_addition_infinity() { diff --git a/src/uucore/src/lib/features/format/argument.rs b/src/uucore/src/lib/features/format/argument.rs index 0718ec662..82ed0ab0f 100644 --- a/src/uucore/src/lib/features/format/argument.rs +++ b/src/uucore/src/lib/features/format/argument.rs @@ -5,7 +5,7 @@ use crate::{ error::set_exit_code, - features::format::num_parser::{ExtendedParser, ExtendedParserError}, + parser::num_parser::{ExtendedParser, ExtendedParserError}, quoting_style::{Quotes, QuotingStyle, escape_name}, show_error, show_warning, }; diff --git a/src/uucore/src/lib/features/format/mod.rs b/src/uucore/src/lib/features/format/mod.rs index 4a0a1a979..3387f15fe 100644 --- a/src/uucore/src/lib/features/format/mod.rs +++ b/src/uucore/src/lib/features/format/mod.rs @@ -33,14 +33,12 @@ mod argument; mod escape; -pub mod extendedbigdecimal; pub mod human; pub mod num_format; -pub mod num_parser; mod spec; +use crate::extendedbigdecimal::ExtendedBigDecimal; pub use argument::*; -pub use extendedbigdecimal::ExtendedBigDecimal; pub use spec::Spec; use std::{ error::Error, diff --git a/src/uucore/src/lib/parser.rs b/src/uucore/src/lib/features/parser/mod.rs similarity index 81% rename from src/uucore/src/lib/parser.rs rename to src/uucore/src/lib/features/parser/mod.rs index a0de6c0d4..800fe6e8c 100644 --- a/src/uucore/src/lib/parser.rs +++ b/src/uucore/src/lib/features/parser/mod.rs @@ -2,6 +2,9 @@ // // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. +// spell-checker:ignore extendedbigdecimal + +pub mod num_parser; pub mod parse_glob; pub mod parse_size; pub mod parse_time; diff --git a/src/uucore/src/lib/features/format/num_parser.rs b/src/uucore/src/lib/features/parser/num_parser.rs similarity index 99% rename from src/uucore/src/lib/features/format/num_parser.rs rename to src/uucore/src/lib/features/parser/num_parser.rs index 1ab889184..083a6ca05 100644 --- a/src/uucore/src/lib/features/format/num_parser.rs +++ b/src/uucore/src/lib/features/parser/num_parser.rs @@ -15,7 +15,7 @@ use num_traits::Signed; use num_traits::ToPrimitive; use num_traits::Zero; -use crate::format::extendedbigdecimal::ExtendedBigDecimal; +use crate::extendedbigdecimal::ExtendedBigDecimal; /// Base for number parsing #[derive(Clone, Copy, PartialEq)] @@ -486,7 +486,7 @@ mod tests { use bigdecimal::BigDecimal; - use crate::format::ExtendedBigDecimal; + use crate::extendedbigdecimal::ExtendedBigDecimal; use super::{ExtendedParser, ExtendedParserError}; diff --git a/src/uucore/src/lib/parser/parse_glob.rs b/src/uucore/src/lib/features/parser/parse_glob.rs similarity index 98% rename from src/uucore/src/lib/parser/parse_glob.rs rename to src/uucore/src/lib/features/parser/parse_glob.rs index 08271788a..6f7dae24c 100644 --- a/src/uucore/src/lib/parser/parse_glob.rs +++ b/src/uucore/src/lib/features/parser/parse_glob.rs @@ -48,7 +48,7 @@ fn fix_negation(glob: &str) -> String { /// /// ```rust /// 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("x")); /// ``` diff --git a/src/uucore/src/lib/parser/parse_size.rs b/src/uucore/src/lib/features/parser/parse_size.rs similarity index 99% rename from src/uucore/src/lib/parser/parse_size.rs rename to src/uucore/src/lib/features/parser/parse_size.rs index b18e1695d..c34db8b14 100644 --- a/src/uucore/src/lib/parser/parse_size.rs +++ b/src/uucore/src/lib/features/parser/parse_size.rs @@ -136,7 +136,7 @@ impl<'parser> Parser<'parser> { /// # Examples /// /// ```rust - /// use uucore::parse_size::Parser; + /// use uucore::parser::parse_size::Parser; /// let parser = Parser { /// default_unit: Some("M"), /// ..Default::default() @@ -346,7 +346,7 @@ impl<'parser> Parser<'parser> { /// # Examples /// /// ```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(9 * 1000), parse_size_u128("9kB")); // kB is 1000 /// assert_eq!(Ok(2 * 1024), parse_size_u128("2K")); // K is 1024 diff --git a/src/uucore/src/lib/parser/parse_time.rs b/src/uucore/src/lib/features/parser/parse_time.rs similarity index 97% rename from src/uucore/src/lib/parser/parse_time.rs rename to src/uucore/src/lib/features/parser/parse_time.rs index d22d4d372..085dfac81 100644 --- a/src/uucore/src/lib/parser/parse_time.rs +++ b/src/uucore/src/lib/features/parser/parse_time.rs @@ -40,7 +40,7 @@ use crate::display::Quotable; /// /// ```rust /// 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("2d"), Ok(Duration::from_secs(60 * 60 * 24 * 2))); /// ``` @@ -84,7 +84,7 @@ pub fn from_str(string: &str) -> Result { #[cfg(test)] mod tests { - use crate::parse_time::from_str; + use crate::parser::parse_time::from_str; use std::time::Duration; #[test] diff --git a/src/uucore/src/lib/parser/shortcut_value_parser.rs b/src/uucore/src/lib/features/parser/shortcut_value_parser.rs similarity index 100% rename from src/uucore/src/lib/parser/shortcut_value_parser.rs rename to src/uucore/src/lib/features/parser/shortcut_value_parser.rs diff --git a/src/uucore/src/lib/features/update_control.rs b/src/uucore/src/lib/features/update_control.rs index 95b403aff..ddb5fdc17 100644 --- a/src/uucore/src/lib/features/update_control.rs +++ b/src/uucore/src/lib/features/update_control.rs @@ -65,7 +65,7 @@ pub enum UpdateMode { pub mod arguments { //! Pre-defined arguments for update functionality. - use crate::shortcut_value_parser::ShortcutValueParser; + use crate::parser::shortcut_value_parser::ShortcutValueParser; use clap::ArgAction; /// `--update` argument diff --git a/src/uucore/src/lib/lib.rs b/src/uucore/src/lib/lib.rs index 8cdd1319f..20e03146c 100644 --- a/src/uucore/src/lib/lib.rs +++ b/src/uucore/src/lib/lib.rs @@ -5,7 +5,7 @@ //! library ~ (core/bundler file) // #![deny(missing_docs)] //TODO: enable this // -// spell-checker:ignore sigaction SIGBUS SIGSEGV +// spell-checker:ignore sigaction SIGBUS SIGSEGV extendedbigdecimal // * feature-gated external crates (re-shared as public internal modules) #[cfg(feature = "libc")] @@ -18,7 +18,6 @@ pub extern crate windows_sys; mod features; // feature-gated code modules mod macros; // crate macros (macro_rules-type; exported to `crate::...`) mod mods; // core cross-platform modules -mod parser; // string parsing modules pub use uucore_procs::*; @@ -31,12 +30,6 @@ pub use crate::mods::os; pub use crate::mods::panic; 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 #[cfg(feature = "backup-control")] pub use crate::features::backup_control; @@ -50,12 +43,16 @@ pub use crate::features::colors; pub use crate::features::custom_tz_fmt; #[cfg(feature = "encoding")] pub use crate::features::encoding; +#[cfg(feature = "extendedbigdecimal")] +pub use crate::features::extendedbigdecimal; #[cfg(feature = "format")] pub use crate::features::format; #[cfg(feature = "fs")] pub use crate::features::fs; #[cfg(feature = "lines")] pub use crate::features::lines; +#[cfg(feature = "parser")] +pub use crate::features::parser; #[cfg(feature = "quoting-style")] pub use crate::features::quoting_style; #[cfg(feature = "ranges")]