mirror of https://github.com/sharkdp/fd.git
commit
a0370aaf25
|
@ -37,17 +37,6 @@ dependencies = [
|
||||||
"nix 0.24.3",
|
"nix 0.24.3",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "atty"
|
|
||||||
version = "0.2.14"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
|
|
||||||
dependencies = [
|
|
||||||
"hermit-abi 0.1.19",
|
|
||||||
"libc",
|
|
||||||
"winapi",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "autocfg"
|
name = "autocfg"
|
||||||
version = "1.1.0"
|
version = "1.1.0"
|
||||||
|
@ -327,7 +316,6 @@ version = "8.7.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"argmax",
|
"argmax",
|
||||||
"atty",
|
|
||||||
"chrono",
|
"chrono",
|
||||||
"clap",
|
"clap",
|
||||||
"clap_complete",
|
"clap_complete",
|
||||||
|
@ -347,7 +335,6 @@ dependencies = [
|
||||||
"normpath",
|
"normpath",
|
||||||
"nu-ansi-term",
|
"nu-ansi-term",
|
||||||
"num_cpus",
|
"num_cpus",
|
||||||
"once_cell",
|
|
||||||
"regex",
|
"regex",
|
||||||
"regex-syntax",
|
"regex-syntax",
|
||||||
"tempfile",
|
"tempfile",
|
||||||
|
@ -404,15 +391,6 @@ version = "0.4.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
|
checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "hermit-abi"
|
|
||||||
version = "0.1.19"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33"
|
|
||||||
dependencies = [
|
|
||||||
"libc",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hermit-abi"
|
name = "hermit-abi"
|
||||||
version = "0.2.6"
|
version = "0.2.6"
|
||||||
|
|
|
@ -18,7 +18,7 @@ readme = "README.md"
|
||||||
repository = "https://github.com/sharkdp/fd"
|
repository = "https://github.com/sharkdp/fd"
|
||||||
version = "8.7.0"
|
version = "8.7.0"
|
||||||
edition= "2021"
|
edition= "2021"
|
||||||
rust-version = "1.67.0"
|
rust-version = "1.70.0"
|
||||||
|
|
||||||
[badges.appveyor]
|
[badges.appveyor]
|
||||||
repository = "sharkdp/fd"
|
repository = "sharkdp/fd"
|
||||||
|
@ -36,7 +36,6 @@ version_check = "0.9"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
nu-ansi-term = "0.47"
|
nu-ansi-term = "0.47"
|
||||||
argmax = "0.3.1"
|
argmax = "0.3.1"
|
||||||
atty = "0.2"
|
|
||||||
ignore = "0.4.20"
|
ignore = "0.4.20"
|
||||||
num_cpus = "1.15"
|
num_cpus = "1.15"
|
||||||
regex = "1.7.3"
|
regex = "1.7.3"
|
||||||
|
@ -47,7 +46,6 @@ globset = "0.4"
|
||||||
anyhow = "1.0"
|
anyhow = "1.0"
|
||||||
dirs-next = "2.0"
|
dirs-next = "2.0"
|
||||||
normpath = "1.1.1"
|
normpath = "1.1.1"
|
||||||
once_cell = "1.17.2"
|
|
||||||
crossbeam-channel = "0.5.8"
|
crossbeam-channel = "0.5.8"
|
||||||
clap_complete = {version = "4.3.0", optional = true}
|
clap_complete = {version = "4.3.0", optional = true}
|
||||||
faccess = "0.2.4"
|
faccess = "0.2.4"
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
|
use std::cell::OnceCell;
|
||||||
use std::ffi::OsString;
|
use std::ffi::OsString;
|
||||||
use std::fs::{FileType, Metadata};
|
use std::fs::{FileType, Metadata};
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
use lscolors::{Colorable, LsColors, Style};
|
use lscolors::{Colorable, LsColors, Style};
|
||||||
|
|
||||||
use once_cell::unsync::OnceCell;
|
|
||||||
|
|
||||||
use crate::config::Config;
|
use crate::config::Config;
|
||||||
use crate::filesystem::strip_current_dir;
|
use crate::filesystem::strip_current_dir;
|
||||||
|
|
||||||
|
|
|
@ -9,11 +9,10 @@ use std::io;
|
||||||
use std::iter;
|
use std::iter;
|
||||||
use std::path::{Component, Path, PathBuf, Prefix};
|
use std::path::{Component, Path, PathBuf, Prefix};
|
||||||
use std::process::Stdio;
|
use std::process::Stdio;
|
||||||
use std::sync::Mutex;
|
use std::sync::{Mutex, OnceLock};
|
||||||
|
|
||||||
use anyhow::{bail, Result};
|
use anyhow::{bail, Result};
|
||||||
use argmax::Command;
|
use argmax::Command;
|
||||||
use once_cell::sync::Lazy;
|
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
|
|
||||||
use crate::exit_codes::{merge_exitcodes, ExitCode};
|
use crate::exit_codes::{merge_exitcodes, ExitCode};
|
||||||
|
@ -231,8 +230,7 @@ impl CommandTemplate {
|
||||||
I: IntoIterator<Item = S>,
|
I: IntoIterator<Item = S>,
|
||||||
S: AsRef<str>,
|
S: AsRef<str>,
|
||||||
{
|
{
|
||||||
static PLACEHOLDER_PATTERN: Lazy<Regex> =
|
static PLACEHOLDER_PATTERN: OnceLock<Regex> = OnceLock::new();
|
||||||
Lazy::new(|| Regex::new(r"\{(/?\.?|//)\}").unwrap());
|
|
||||||
|
|
||||||
let mut args = Vec::new();
|
let mut args = Vec::new();
|
||||||
let mut has_placeholder = false;
|
let mut has_placeholder = false;
|
||||||
|
@ -243,7 +241,10 @@ impl CommandTemplate {
|
||||||
let mut tokens = Vec::new();
|
let mut tokens = Vec::new();
|
||||||
let mut start = 0;
|
let mut start = 0;
|
||||||
|
|
||||||
for placeholder in PLACEHOLDER_PATTERN.find_iter(arg) {
|
let pattern =
|
||||||
|
PLACEHOLDER_PATTERN.get_or_init(|| Regex::new(r"\{(/?\.?|//)\}").unwrap());
|
||||||
|
|
||||||
|
for placeholder in pattern.find_iter(arg) {
|
||||||
// Leading text before the placeholder.
|
// Leading text before the placeholder.
|
||||||
if placeholder.start() > start {
|
if placeholder.start() > start {
|
||||||
tokens.push(Token::Text(arg[start..placeholder.start()].to_owned()));
|
tokens.push(Token::Text(arg[start..placeholder.start()].to_owned()));
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
|
use std::sync::OnceLock;
|
||||||
|
|
||||||
use anyhow::anyhow;
|
use anyhow::anyhow;
|
||||||
use once_cell::sync::Lazy;
|
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
|
|
||||||
static SIZE_CAPTURES: Lazy<Regex> =
|
static SIZE_CAPTURES: OnceLock<Regex> = OnceLock::new();
|
||||||
Lazy::new(|| Regex::new(r"(?i)^([+-]?)(\d+)(b|[kmgt]i?b?)$").unwrap());
|
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||||
pub enum SizeFilter {
|
pub enum SizeFilter {
|
||||||
|
@ -31,11 +31,13 @@ impl SizeFilter {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_opt(s: &str) -> Option<Self> {
|
fn parse_opt(s: &str) -> Option<Self> {
|
||||||
if !SIZE_CAPTURES.is_match(s) {
|
let pattern =
|
||||||
|
SIZE_CAPTURES.get_or_init(|| Regex::new(r"(?i)^([+-]?)(\d+)(b|[kmgt]i?b?)$").unwrap());
|
||||||
|
if !pattern.is_match(s) {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
let captures = SIZE_CAPTURES.captures(s)?;
|
let captures = pattern.captures(s)?;
|
||||||
let limit_kind = captures.get(1).map_or("+", |m| m.as_str());
|
let limit_kind = captures.get(1).map_or("+", |m| m.as_str());
|
||||||
let quantity = captures
|
let quantity = captures
|
||||||
.get(2)
|
.get(2)
|
||||||
|
|
|
@ -12,12 +12,12 @@ mod regex_helper;
|
||||||
mod walk;
|
mod walk;
|
||||||
|
|
||||||
use std::env;
|
use std::env;
|
||||||
|
use std::io::IsTerminal;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::time;
|
use std::time;
|
||||||
|
|
||||||
use anyhow::{anyhow, bail, Context, Result};
|
use anyhow::{anyhow, bail, Context, Result};
|
||||||
use atty::Stream;
|
|
||||||
use clap::{CommandFactory, Parser};
|
use clap::{CommandFactory, Parser};
|
||||||
use globset::GlobBuilder;
|
use globset::GlobBuilder;
|
||||||
use lscolors::LsColors;
|
use lscolors::LsColors;
|
||||||
|
@ -217,7 +217,7 @@ fn construct_config(mut opts: Opts, pattern_regexps: &[String]) -> Result<Config
|
||||||
#[cfg(not(windows))]
|
#[cfg(not(windows))]
|
||||||
let ansi_colors_support = true;
|
let ansi_colors_support = true;
|
||||||
|
|
||||||
let interactive_terminal = atty::is(Stream::Stdout);
|
let interactive_terminal = std::io::stdout().is_terminal();
|
||||||
let colored_output = match opts.color {
|
let colored_output = match opts.color {
|
||||||
ColorWhen::Always => true,
|
ColorWhen::Always => true,
|
||||||
ColorWhen::Never => false,
|
ColorWhen::Never => false,
|
||||||
|
|
Loading…
Reference in New Issue