mirror of
https://github.com/sharkdp/fd.git
synced 2024-11-17 09:28:25 +01:00
Remove strip-prefix placeholders
This commit is contained in:
parent
f347379fb0
commit
47421a49b8
3 changed files with 1 additions and 26 deletions
|
@ -19,7 +19,6 @@ use self::command::execute_command;
|
||||||
use self::input::{basename, dirname, remove_extension};
|
use self::input::{basename, dirname, remove_extension};
|
||||||
pub use self::job::{batch, job};
|
pub use self::job::{batch, job};
|
||||||
use self::token::Token;
|
use self::token::Token;
|
||||||
use crate::filesystem::strip_current_dir;
|
|
||||||
|
|
||||||
/// Execution mode of the command
|
/// Execution mode of the command
|
||||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||||
|
@ -73,7 +72,7 @@ impl CommandTemplate {
|
||||||
S: AsRef<str>,
|
S: AsRef<str>,
|
||||||
{
|
{
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
static ref PLACEHOLDER_PATTERN: Regex = Regex::new(r"\{(/?\.?|//|-|//-)\}").unwrap();
|
static ref PLACEHOLDER_PATTERN: Regex = Regex::new(r"\{(/?\.?|//)\}").unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut args = Vec::new();
|
let mut args = Vec::new();
|
||||||
|
@ -99,8 +98,6 @@ impl CommandTemplate {
|
||||||
"{/}" => tokens.push(Token::Basename),
|
"{/}" => tokens.push(Token::Basename),
|
||||||
"{//}" => tokens.push(Token::Parent),
|
"{//}" => tokens.push(Token::Parent),
|
||||||
"{/.}" => tokens.push(Token::BasenameNoExt),
|
"{/.}" => tokens.push(Token::BasenameNoExt),
|
||||||
"{-}" => tokens.push(Token::StripPrefix),
|
|
||||||
"{//-}" => tokens.push(Token::ParentStripPrefix),
|
|
||||||
_ => unreachable!("Unhandled placeholder"),
|
_ => unreachable!("Unhandled placeholder"),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -234,14 +231,6 @@ impl ArgumentTemplate {
|
||||||
Placeholder => {
|
Placeholder => {
|
||||||
s.push(Self::replace_separator(path.as_ref(), path_separator))
|
s.push(Self::replace_separator(path.as_ref(), path_separator))
|
||||||
}
|
}
|
||||||
StripPrefix => {
|
|
||||||
let path = strip_current_dir(path);
|
|
||||||
s.push(Self::replace_separator(path.as_ref(), path_separator))
|
|
||||||
}
|
|
||||||
ParentStripPrefix => {
|
|
||||||
let path = strip_current_dir(path);
|
|
||||||
s.push(Self::replace_separator(&dirname(path), path_separator))
|
|
||||||
}
|
|
||||||
Text(ref string) => s.push(string),
|
Text(ref string) => s.push(string),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,8 +11,6 @@ pub enum Token {
|
||||||
Parent,
|
Parent,
|
||||||
NoExt,
|
NoExt,
|
||||||
BasenameNoExt,
|
BasenameNoExt,
|
||||||
StripPrefix,
|
|
||||||
ParentStripPrefix,
|
|
||||||
Text(String),
|
Text(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,8 +22,6 @@ impl Display for Token {
|
||||||
Token::Parent => f.write_str("{//}")?,
|
Token::Parent => f.write_str("{//}")?,
|
||||||
Token::NoExt => f.write_str("{.}")?,
|
Token::NoExt => f.write_str("{.}")?,
|
||||||
Token::BasenameNoExt => f.write_str("{/.}")?,
|
Token::BasenameNoExt => f.write_str("{/.}")?,
|
||||||
Token::StripPrefix => f.write_str("{-}")?,
|
|
||||||
Token::ParentStripPrefix => f.write_str("{//-}")?,
|
|
||||||
Token::Text(ref string) => f.write_str(string)?,
|
Token::Text(ref string) => f.write_str(string)?,
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
@ -1363,16 +1363,6 @@ fn test_exec() {
|
||||||
);
|
);
|
||||||
|
|
||||||
te.assert_output(&["e1", "--exec", "printf", "%s.%s\n"], "./e1 e2.");
|
te.assert_output(&["e1", "--exec", "printf", "%s.%s\n"], "./e1 e2.");
|
||||||
|
|
||||||
te.assert_output(
|
|
||||||
&["foo", "--exec", "echo", "{-}"],
|
|
||||||
"a.foo
|
|
||||||
one/b.foo
|
|
||||||
one/two/C.Foo2
|
|
||||||
one/two/c.foo
|
|
||||||
one/two/three/d.foo
|
|
||||||
one/two/three/directory_foo",
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue