mirror of
https://github.com/TECHNOFAB11/pay-respects.git
synced 2025-12-12 06:20:09 +01:00
fix: actually using the regex capture
This commit is contained in:
parent
05a3fe7e87
commit
1d26ca5c7e
2 changed files with 8 additions and 59 deletions
|
|
@ -2,61 +2,10 @@ command = "cargo"
|
||||||
|
|
||||||
[[match_err]]
|
[[match_err]]
|
||||||
pattern = [
|
pattern = [
|
||||||
"no such command"
|
"did you mean"
|
||||||
]
|
]
|
||||||
suggest = [
|
suggest = [
|
||||||
'''
|
'''
|
||||||
{{command[0]}} {{typo[1](
|
{{command[0]}} {{err::(?:did you mean `)(.*)(?:`)}} {{command[2:]}} '''
|
||||||
add,
|
|
||||||
b,
|
|
||||||
bench,
|
|
||||||
build,
|
|
||||||
c,
|
|
||||||
check,
|
|
||||||
clean,
|
|
||||||
clippy,
|
|
||||||
config,
|
|
||||||
d,
|
|
||||||
doc,
|
|
||||||
expand,
|
|
||||||
fetch,
|
|
||||||
fix,
|
|
||||||
fmt,
|
|
||||||
generate-lockfile,
|
|
||||||
git-checkout,
|
|
||||||
help,
|
|
||||||
init,
|
|
||||||
install,
|
|
||||||
lipo,
|
|
||||||
locate-project,
|
|
||||||
login,
|
|
||||||
logout,
|
|
||||||
make,
|
|
||||||
metadata,
|
|
||||||
miri,
|
|
||||||
new,
|
|
||||||
owner,
|
|
||||||
package,
|
|
||||||
pkgid,
|
|
||||||
publish,
|
|
||||||
r,
|
|
||||||
read-manifest,
|
|
||||||
remove,
|
|
||||||
report,
|
|
||||||
rm,
|
|
||||||
run,
|
|
||||||
rustc,
|
|
||||||
rustdoc,
|
|
||||||
search,
|
|
||||||
t,
|
|
||||||
test,
|
|
||||||
tree,
|
|
||||||
uninstall,
|
|
||||||
update,
|
|
||||||
vendor,
|
|
||||||
verify-project,
|
|
||||||
version,
|
|
||||||
yank
|
|
||||||
)}} {{command[2:]}}'''
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -81,8 +81,8 @@ pub fn check_executable(shell: &str, executable: &str) -> bool {
|
||||||
pub fn opt_regex(regex: &str, command: &mut String) -> String {
|
pub fn opt_regex(regex: &str, command: &mut String) -> String {
|
||||||
let regex = Regex::new(regex).unwrap();
|
let regex = Regex::new(regex).unwrap();
|
||||||
let opts = regex
|
let opts = regex
|
||||||
.find_iter(command)
|
.captures_iter(command)
|
||||||
.map(|cap| cap.as_str().to_owned())
|
.map(|cap| cap.get(1).unwrap().as_str().to_owned())
|
||||||
.collect::<Vec<String>>();
|
.collect::<Vec<String>>();
|
||||||
for opt in opts.clone() {
|
for opt in opts.clone() {
|
||||||
*command = command.replace(&opt, "");
|
*command = command.replace(&opt, "");
|
||||||
|
|
@ -94,8 +94,8 @@ pub fn opt_regex(regex: &str, command: &mut String) -> String {
|
||||||
pub fn err_regex(regex: &str, error_msg: &str) -> String {
|
pub fn err_regex(regex: &str, error_msg: &str) -> String {
|
||||||
let regex = Regex::new(regex).unwrap();
|
let regex = Regex::new(regex).unwrap();
|
||||||
let err = regex
|
let err = regex
|
||||||
.find_iter(error_msg)
|
.captures_iter(error_msg)
|
||||||
.map(|cap| cap.as_str().to_owned())
|
.map(|cap| cap.get(1).unwrap().as_str().to_owned())
|
||||||
.collect::<Vec<String>>();
|
.collect::<Vec<String>>();
|
||||||
|
|
||||||
err.join(" ")
|
err.join(" ")
|
||||||
|
|
@ -104,8 +104,8 @@ pub fn err_regex(regex: &str, error_msg: &str) -> String {
|
||||||
pub fn cmd_regex(regex: &str, command: &str) -> String {
|
pub fn cmd_regex(regex: &str, command: &str) -> String {
|
||||||
let regex = Regex::new(regex).unwrap();
|
let regex = Regex::new(regex).unwrap();
|
||||||
let err = regex
|
let err = regex
|
||||||
.find_iter(command)
|
.captures_iter(command)
|
||||||
.map(|cap| cap.as_str().to_owned())
|
.map(|cap| cap.get(1).unwrap().as_str().to_owned())
|
||||||
.collect::<Vec<String>>();
|
.collect::<Vec<String>>();
|
||||||
|
|
||||||
err.join(" ")
|
err.join(" ")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue