aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock2
-rw-r--r--Cargo.toml2
-rw-r--r--src/lib.rs61
3 files changed, 35 insertions, 30 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 5e30856..7df14c3 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -4,7 +4,7 @@ version = 3
[[package]]
name = "s3g"
-version = "1.0.1"
+version = "1.0.2"
dependencies = [
"toml",
]
diff --git a/Cargo.toml b/Cargo.toml
index 897b071..56b7de9 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "s3g"
-version = "1.0.1"
+version = "1.0.2"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
diff --git a/src/lib.rs b/src/lib.rs
index bb60fca..542d39f 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -231,42 +231,47 @@ impl S3G {
if line.contains(&self.config.file_delim) || line.contains(&self.config.command_delim) {
+ // Setup the line for parsing
+ let mut v = line.trim().split(':');
+ // make sure to push the first string
+ match v.next() {
+ None => (),
+ Some(n) => file_string.push_str(n),
+ };
+ let v: Vec<String> = v.map(|x| (String::from(':') + x)).collect();
+
// Parse lines for prefixes
- let v: Vec<&str> = line.trim().split(':').collect();
- for s in v {
- let s = match s {
- "" => String::from(""),
- n => {
- let mut string = String::new();
- // Commands
- for c in &self.config.commands {
- let delim = String::new() + &self.config.command_delim.get(1..2).unwrap() + &c.0;
- if n.contains(&delim) {
- let n = n.replace(&delim, &c.1);
- string.push_str(&n);
- }
+ for n in v {
+ let n = {
+ let mut string = String::new();
+ // Commands
+ for c in &self.config.commands {
+ let delim = String::new() + &self.config.command_delim + &c.0;
+ if n.contains(&delim) {
+ let n = n.replace(&delim, &c.1);
+ string.push_str(&n);
}
+ }
- // Files
- if n.contains(&self.config.file_delim.get(1..2).unwrap()) {
- let n: Vec<&str> = n.split(&self.config.file_delim.get(1..2).unwrap()).collect();
- for s in n {
- let s = match s {
- "" => String::from(""),
- // Scan the file from the path
- n => self.file_scan(&path::PathBuf::from(n)).unwrap_or(String::from("")),
- };
+ // Files
+ if n.contains(&self.config.file_delim) {
+ let n: Vec<&str> = n.split(&self.config.file_delim).collect();
+ for s in n {
+ let s = match s {
+ "" => String::from(""),
+ // Scan the file from the path
+ n => self.file_scan(&path::PathBuf::from(n)).unwrap_or(String::from("")),
+ };
- string.push_str(&s);
- }
-
+ string.push_str(&s);
}
- string
- },
+
+ }
+ string
};
// Push matching and scanned string
- file_string.push_str(&s);
+ file_string.push_str(&n);
file_string.push('\n');
}