mirror of
https://github.com/msfjarvis/clipboard-substitutor
synced 2025-08-14 20:07:01 +05:30
config: add support for Matcher::Exactly
and Action::Set
This commit is contained in:
parent
a357b02712
commit
51e7c4a74c
1 changed files with 6 additions and 0 deletions
|
@ -29,10 +29,14 @@ pub enum Matcher<'config> {
|
||||||
Contains { substring: &'config str },
|
Contains { substring: &'config str },
|
||||||
#[serde(rename = "regex")]
|
#[serde(rename = "regex")]
|
||||||
Regex { pattern: &'config str },
|
Regex { pattern: &'config str },
|
||||||
|
#[serde(rename = "exactly")]
|
||||||
|
Exactly { content: &'config str },
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Deserialize)]
|
#[derive(Clone, Debug, Deserialize)]
|
||||||
pub enum Action<'config> {
|
pub enum Action<'config> {
|
||||||
|
#[serde(rename = "set")]
|
||||||
|
Set { content: &'config str },
|
||||||
#[serde(rename = "replace")]
|
#[serde(rename = "replace")]
|
||||||
Replace {
|
Replace {
|
||||||
from: &'config str,
|
from: &'config str,
|
||||||
|
@ -62,6 +66,7 @@ impl Match for Matcher<'_> {
|
||||||
let regex = Regex::from_str(pattern).expect("Failed to parse regex");
|
let regex = Regex::from_str(pattern).expect("Failed to parse regex");
|
||||||
regex.is_match(string)
|
regex.is_match(string)
|
||||||
}
|
}
|
||||||
|
Matcher::Exactly { content } => string == content,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -72,6 +77,7 @@ impl Act for Action<'_> {
|
||||||
Action::Replace { from, to } => input.replace(from, to),
|
Action::Replace { from, to } => input.replace(from, to),
|
||||||
Action::Prefix { prefix } => format!("{}{}", prefix, input),
|
Action::Prefix { prefix } => format!("{}{}", prefix, input),
|
||||||
Action::Suffix { suffix } => format!("{}{}", input, suffix),
|
Action::Suffix { suffix } => format!("{}{}", input, suffix),
|
||||||
|
Action::Set { content } => content.to_owned(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue