mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 03:27:44 +00:00
tail: clean up some small things in input parsing
This commit is contained in:
parent
ae60045f3f
commit
5a667db43d
2 changed files with 5 additions and 9 deletions
|
@ -7,7 +7,7 @@
|
|||
|
||||
use crate::paths::Input;
|
||||
use crate::{parse, platform, Quotable};
|
||||
use clap::crate_version;
|
||||
use clap::{crate_version, value_parser};
|
||||
use clap::{Arg, ArgAction, ArgMatches, Command};
|
||||
use fundu::DurationParser;
|
||||
use is_terminal::IsTerminal;
|
||||
|
@ -283,7 +283,7 @@ impl Settings {
|
|||
}
|
||||
|
||||
settings.inputs = matches
|
||||
.get_raw(options::ARG_FILES)
|
||||
.get_many::<OsString>(options::ARG_FILES)
|
||||
.map(|v| v.map(Input::from).collect())
|
||||
.unwrap_or_else(|| vec![Input::default()]);
|
||||
|
||||
|
@ -584,6 +584,7 @@ pub fn uu_app() -> Command {
|
|||
Arg::new(options::ARG_FILES)
|
||||
.action(ArgAction::Append)
|
||||
.num_args(1..)
|
||||
.value_parser(value_parser!(OsString))
|
||||
.value_hint(clap::ValueHint::FilePath),
|
||||
)
|
||||
}
|
||||
|
|
|
@ -10,10 +10,7 @@ use std::ffi::OsStr;
|
|||
use std::fs::{File, Metadata};
|
||||
use std::io::{Seek, SeekFrom};
|
||||
#[cfg(unix)]
|
||||
use std::os::unix::{
|
||||
fs::{FileTypeExt, MetadataExt},
|
||||
prelude::OsStrExt,
|
||||
};
|
||||
use std::os::unix::fs::{FileTypeExt, MetadataExt};
|
||||
use std::path::{Path, PathBuf};
|
||||
use uucore::error::UResult;
|
||||
|
||||
|
@ -26,9 +23,7 @@ pub enum InputKind {
|
|||
#[cfg(unix)]
|
||||
impl From<&OsStr> for InputKind {
|
||||
fn from(value: &OsStr) -> Self {
|
||||
const DASH: [u8; 1] = [b'-'];
|
||||
|
||||
if value.as_bytes() == DASH {
|
||||
if value == OsStr::new("-") {
|
||||
Self::Stdin
|
||||
} else {
|
||||
Self::File(PathBuf::from(value))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue