[script] add sendmail function to log_editor

This commit is contained in:
Mathieu Maret 2011-11-17 17:30:26 +01:00
parent fe0a585043
commit 26680c771c

View File

@ -21,7 +21,7 @@ SPM=60
MPH=60 MPH=60
HPD=24 HPD=24
mode_available="view edit list toMail todo" mode_available="view edit list toMail todo sendMail"
usage () { usage () {
echo "usage : ${0##*/} MODE [DATE|select] " echo "usage : ${0##*/} MODE [DATE|select] "
@ -108,6 +108,17 @@ toMail () {
view $1 view $1
} }
sendMail () {
read_date $1
date_arg=$?
curr_day=$(date --date="$date_arg days ago" +%u)
day_to_monday=$(($curr_day -1))
day_to_friday=$((5 - $curr_day))
start_date=$(date --date="$((date_arg + day_to_monday)) days ago" +%Y-%m-%d)
stop_date=$(date --date="$((date_arg + day_to_friday)) days" +%Y-%m-%d)
view $1 |mail -s "Weekly $start_date -> $stop_date" $USER@dxo.com
}
todo () { todo () {
${EDITOR} $log_directory/TODO ${EDITOR} $log_directory/TODO
} }