taro-ctl: add mblaze commands for search, refile, trash
This commit is contained in:
parent
bb102262e5
commit
4521ea05a1
1 changed files with 23 additions and 8 deletions
31
taro-ctl.cr
31
taro-ctl.cr
|
@ -143,30 +143,45 @@ module Taro
|
||||||
return io.to_s
|
return io.to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
def list_mail
|
def list_mail : String
|
||||||
mailCmd = "
|
cmd = "
|
||||||
mbox=${MBOX_ROOT}/#{@mailbox}
|
mbox=${MBOX_ROOT}/#{@mailbox}
|
||||||
|
|
||||||
mdirs ${mbox} | xargs minc > /dev/null
|
mdirs ${mbox} | xargs minc > /dev/null
|
||||||
mlist ${mbox} | msort -dr | mseq -S | mscan"
|
mlist ${mbox} | msort -dr | mseq -S | mscan"
|
||||||
|
|
||||||
return run_cmd(mailCmd)
|
return run_cmd(cmd)
|
||||||
end
|
end
|
||||||
|
|
||||||
def list_mboxes
|
def list_mboxes : String
|
||||||
mailCmd ="echo 'INBOX' ; for x in $(mdirs -a ${MBOX_ROOT} | sort | grep -v INBOX); do echo ${x#$MBOX_ROOT/}; done"
|
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
|
end
|
||||||
|
|
||||||
def mark_all_read
|
def mark_all_read
|
||||||
mailCmd = "mflag -S :"
|
cmd = "mflag -S :"
|
||||||
return run_cmd(mailCmd)
|
run_cmd(cmd)
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_mbox(box : String)
|
def set_mbox(box : String)
|
||||||
@mailbox = box
|
@mailbox = box
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
class TaroCtl
|
class TaroCtl
|
||||||
|
|
Loading…
Reference in a new issue