]> git.scottworley.com Git - tablify/blobdiff - src/lib.rs
Release 0.6.0
[tablify] / src / lib.rs
index 4deceffb5ff53677903e6f4e2a46a93d7390a462..e199470146730fd89cfea466878f926d0c42e488 100644 (file)
@@ -50,6 +50,16 @@ impl Config {
                     .substitute_labels
                     .insert(col.to_owned(), label.to_owned()),
             };
+        } else if let Some(directive) = cmd.strip_prefix("mark ") {
+            match directive.split_once(':') {
+                None => {
+                    return Err(std::io::Error::new(
+                        std::io::ErrorKind::InvalidInput,
+                        format!("line {line_num}: Mark missing ':'"),
+                    ))
+                }
+                Some((col, label)) => self.mark.insert(col.to_owned(), label.to_owned()),
+            };
         } else {
             return Err(std::io::Error::new(
                 std::io::ErrorKind::InvalidInput,
@@ -641,6 +651,7 @@ mod tests {
                 .substitute_labels["foo"],
             "bar"
         );
+        assert_eq!(read_config(&b"!mark foo:*"[..]).unwrap().mark["foo"], "*");
 
         let bad_command = read_config(&b"!no such command"[..]);
         assert!(bad_command.is_err());
@@ -653,6 +664,10 @@ mod tests {
         let bad_sub = read_config(&b"!label foo"[..]);
         assert!(bad_sub.is_err());
         assert!(format!("{bad_sub:?}").contains("line 1: Annotation missing ':'"));
+
+        let bad_mark = read_config(&b"!mark foo"[..]);
+        assert!(bad_mark.is_err());
+        assert!(format!("{bad_mark:?}").contains("line 1: Mark missing ':'"));
     }
 
     #[test]