Remove strip-prefix placeholders

This commit is contained in:
David Peter 2021-11-26 17:52:46 +01:00
parent f347379fb0
commit 47421a49b8
3 changed files with 1 additions and 26 deletions

View file

@ -19,7 +19,6 @@ use self::command::execute_command;
use self::input::{basename, dirname, remove_extension};
pub use self::job::{batch, job};
use self::token::Token;
use crate::filesystem::strip_current_dir;
/// Execution mode of the command
#[derive(Debug, Clone, Copy, PartialEq)]
@ -73,7 +72,7 @@ impl CommandTemplate {
S: AsRef<str>,
{
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();
@ -99,8 +98,6 @@ impl CommandTemplate {
"{/}" => tokens.push(Token::Basename),
"{//}" => tokens.push(Token::Parent),
"{/.}" => tokens.push(Token::BasenameNoExt),
"{-}" => tokens.push(Token::StripPrefix),
"{//-}" => tokens.push(Token::ParentStripPrefix),
_ => unreachable!("Unhandled placeholder"),
}
@ -234,14 +231,6 @@ impl ArgumentTemplate {
Placeholder => {
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),
}
}

View file

@ -11,8 +11,6 @@ pub enum Token {
Parent,
NoExt,
BasenameNoExt,
StripPrefix,
ParentStripPrefix,
Text(String),
}
@ -24,8 +22,6 @@ impl Display for Token {
Token::Parent => f.write_str("{//}")?,
Token::NoExt => 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)?,
}
Ok(())

View file

@ -1363,16 +1363,6 @@ fn test_exec() {
);
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",
);
}
}