mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-27 19:17:43 +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"] }
|
||||
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/" }
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -33,6 +33,7 @@ uucore = { workspace = true, features = [
|
|||
"entries",
|
||||
"fs",
|
||||
"fsxattr",
|
||||
"parser",
|
||||
"perms",
|
||||
"mode",
|
||||
"update-control",
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -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";
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 }
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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};
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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";
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -34,6 +34,7 @@ uucore = { workspace = true, features = [
|
|||
"format",
|
||||
"fs",
|
||||
"fsxattr",
|
||||
"parser",
|
||||
"quoting-style",
|
||||
"version-cmp",
|
||||
] }
|
||||
|
|
|
@ -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};
|
||||
|
|
|
@ -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]]
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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<u64, ParseSizeError> {
|
||||
let mut start = 0;
|
||||
|
|
|
@ -26,6 +26,7 @@ thiserror = { workspace = true }
|
|||
uucore = { workspace = true, features = [
|
||||
"extendedbigdecimal",
|
||||
"format",
|
||||
"parser",
|
||||
"quoting-style",
|
||||
] }
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
//! [`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::extendedbigdecimal::ExtendedBigDecimal;
|
||||
|
|
|
@ -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]]
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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 }
|
||||
|
|
|
@ -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};
|
||||
|
||||
|
|
|
@ -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]]
|
||||
|
|
|
@ -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};
|
||||
|
|
|
@ -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`]
|
||||
|
|
|
@ -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" }
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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 }
|
||||
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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::<String>(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::<String>(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::<String>(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);
|
||||
|
|
|
@ -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 = [
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -18,7 +18,7 @@ path = "src/truncate.rs"
|
|||
|
||||
[dependencies]
|
||||
clap = { workspace = true }
|
||||
uucore = { workspace = true }
|
||||
uucore = { workspace = true, features = ["parser"] }
|
||||
|
||||
[[bin]]
|
||||
name = "truncate"
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -18,7 +18,7 @@ path = "src/uniq.rs"
|
|||
|
||||
[dependencies]
|
||||
clap = { workspace = true }
|
||||
uucore = { workspace = true }
|
||||
uucore = { workspace = true, features = ["parser"] }
|
||||
|
||||
[[bin]]
|
||||
name = "uniq"
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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 }
|
||||
|
|
|
@ -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,
|
||||
};
|
||||
|
||||
|
|
|
@ -101,6 +101,7 @@ format = [
|
|||
"bigdecimal",
|
||||
"extendedbigdecimal",
|
||||
"itertools",
|
||||
"parser",
|
||||
"num-traits",
|
||||
"quoting-style",
|
||||
]
|
||||
|
@ -113,6 +114,7 @@ proc-info = ["tty", "walkdir"]
|
|||
quoting-style = []
|
||||
ranges = []
|
||||
ringbuffer = []
|
||||
parser = ["extendedbigdecimal", "num-traits"]
|
||||
signals = []
|
||||
sum = [
|
||||
"digest",
|
||||
|
@ -127,7 +129,7 @@ sum = [
|
|||
"sm3",
|
||||
"crc32fast",
|
||||
]
|
||||
update-control = []
|
||||
update-control = ["parser"]
|
||||
utf8 = []
|
||||
utmpx = ["time", "time/macros", "libc", "dns-lookup"]
|
||||
version-cmp = []
|
||||
|
|
|
@ -28,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")]
|
||||
|
|
|
@ -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,
|
||||
};
|
||||
|
|
|
@ -35,7 +35,6 @@ mod argument;
|
|||
mod escape;
|
||||
pub mod human;
|
||||
pub mod num_format;
|
||||
pub mod num_parser;
|
||||
mod spec;
|
||||
|
||||
use crate::extendedbigdecimal::ExtendedBigDecimal;
|
||||
|
|
|
@ -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;
|
|
@ -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"));
|
||||
/// ```
|
|
@ -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
|
|
@ -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<Duration, String> {
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
|
||||
use crate::parse_time::from_str;
|
||||
use crate::parser::parse_time::from_str;
|
||||
use std::time::Duration;
|
||||
|
||||
#[test]
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
@ -58,6 +51,8 @@ pub use crate::features::format;
|
|||
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")]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue