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
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue