taro-ctl: add mblaze commands for search, refile, trash

This commit is contained in:
Iris Lightshard 2023-03-20 22:52:51 -06:00
parent bb102262e5
commit 4521ea05a1
Signed by: Iris Lightshard
GPG key ID: 3B7FBC22144E6398

View file

@ -143,30 +143,45 @@ module Taro
return io.to_s
end
def list_mail
mailCmd = "
def list_mail : String
cmd = "
mbox=${MBOX_ROOT}/#{@mailbox}
mdirs ${mbox} | xargs minc > /dev/null
mlist ${mbox} | msort -dr | mseq -S | mscan"
return run_cmd(mailCmd)
return run_cmd(cmd)
end
def list_mboxes
mailCmd ="echo 'INBOX' ; for x in $(mdirs -a ${MBOX_ROOT} | sort | grep -v INBOX); do echo ${x#$MBOX_ROOT/}; done"
def list_mboxes : String
cmd = "echo 'INBOX' ; for x in $(mdirs -a ${MBOX_ROOT} | sort | grep -v INBOX); do echo ${x#$MBOX_ROOT/}; done"
return run_cmd(mailCmd)
return run_cmd(cmd)
end
def mark_all_read
mailCmd = "mflag -S :"
return run_cmd(mailCmd)
cmd = "mflag -S :"
run_cmd(cmd)
end
def set_mbox(box : String)
@mailbox = box
end
def trash_mail(range : String)
cmd = "mflag -T #{range}; mlist ${MBOX_ROOT}/#{@mailbox} | mseq -S | mpick -t 'trashed' | mrefile ${MBOX_ROOT}/Trash"
run_cmd(cmd)
end
def refile_mail(range : String, to_mbox : String)
cmd = "mrefile #{range} ${MBOX_ROOT}/#{to_mbox}"
run_cmd(cmd)
end
def search_mail(query : String, body : Bool) : String
mailCmd = "mlist ${MBOX_ROOT}/#{@mailbox} | magrep #{body ? "/" : "*"} | msort -dr | mseq -S | mscan | uniq"
return run_cmd(cmd)
end
end
class TaroCtl