diff --git a/Cargo.toml b/Cargo.toml index 7a8ae51..7396807 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,7 +23,7 @@ regex-lite = "0.1" toml = { version = "0.7", optional = true } serde = { version = "1.0", features = ["derive"], optional = true } -pay-respects-parser = "0.2.3" +pay-respects-parser = "0.2.4" # pay-respects-parser = { path = "../pay-respects-parser" } diff --git a/rules/mv.toml b/rules/mv.toml new file mode 100644 index 0000000..b890330 --- /dev/null +++ b/rules/mv.toml @@ -0,0 +1,12 @@ +command = "mv" + +[[match_err]] +pattern = [ + "no such file or directory" +] +suggest = [ +''' +mkdir --parents {{command[-1]}} && \ +{{command}} ''' +] + diff --git a/src/replaces.rs b/src/replaces.rs index fffd65e..9e179a1 100644 --- a/src/replaces.rs +++ b/src/replaces.rs @@ -57,7 +57,7 @@ pub fn command(suggest: &mut String, split_command: &Vec) { if let Some((start, end)) = range.split_once(':') { let mut start_index = start.parse::().unwrap_or(0); if start_index < 0 { - start_index = split_command.len() as i32 - start_index; + start_index = split_command.len() as i32 + start_index; }; let mut end_index; let parsed_end = end.parse::(); @@ -66,7 +66,7 @@ pub fn command(suggest: &mut String, split_command: &Vec) { } else { end_index = parsed_end.unwrap(); if end_index < 0 { - end_index = split_command.len() as i32 - end_index + 1; + end_index = split_command.len() as i32 + end_index + 1; } else { end_index = end_index + 1; } @@ -97,7 +97,7 @@ pub fn typo(suggest: &mut String, split_command: &Vec) { let command_index = command_index.parse::().unwrap(); let index = if command_index < 0 { - split_command.len() as i32 - command_index + split_command.len() as i32 + command_index } else { command_index }; @@ -106,7 +106,7 @@ pub fn typo(suggest: &mut String, split_command: &Vec) { let (start, end) = command_index.split_once(':').unwrap(); let start = start.parse::().unwrap_or(0); let start_index = if start < 0 { - split_command.len() as i32 - start + split_command.len() as i32 + start } else { start }; @@ -116,7 +116,7 @@ pub fn typo(suggest: &mut String, split_command: &Vec) { } else { let end = end.unwrap(); if end < 0 { - split_command.len() as i32 - end + 1 + split_command.len() as i32 + end + 1 } else { end + 1 }