diff --git a/notmuch/src/lib.rs b/notmuch/src/lib.rs index 7ec60e4..714c89e 100644 --- a/notmuch/src/lib.rs +++ b/notmuch/src/lib.rs @@ -480,11 +480,25 @@ impl Notmuch { self.run_notmuch(std::iter::empty::<&str>()) } - pub fn tags(&self) -> Result, NotmuchError> { - let res = self.run_notmuch(["search", "--format=json", "--output=tags", "*"])?; + pub fn tags_for_query(&self, query: &str) -> Result, NotmuchError> { + let res = self.run_notmuch(["search", "--format=json", "--output=tags", query])?; Ok(serde_json::from_slice(&res)?) } + pub fn tags(&self) -> Result, NotmuchError> { + self.tags_for_query("*") + } + + pub fn tag_add(&self, tag: &str, search_term: &str) -> Result<(), NotmuchError> { + self.run_notmuch(["tag", &format!("+{tag}"), search_term])?; + Ok(()) + } + + pub fn tag_remove(&self, tag: &str, search_term: &str) -> Result<(), NotmuchError> { + self.run_notmuch(["tag", &format!("-{tag}"), search_term])?; + Ok(()) + } + pub fn search( &self, query: &str, @@ -514,7 +528,7 @@ impl Notmuch { let slice = self.run_notmuch([ "show", "--include-html=true", - "--entire-thread=true", + "--entire-thread=false", "--format=json", query, ])?;