Browse Source

now moves incomplete items from the previous day to a new section today and supports manual "transfer"

master
Ben Savage 3 years ago
parent
commit
0981510973
  1. 62
      cl

62
cl

@ -122,15 +122,29 @@ function schedule() {
echo "$@" >> "$CLDIR/scheduled" echo "$@" >> "$CLDIR/scheduled"
} }
function prev_working_day() {
if [ "$(date +%a)" == 'Mon' ]; then modY=3;fi
date +%F -d "-${modY:-1} day"
}
function today() {
date +%F
}
function next_working_day() {
if [ "$(date +%a)" == 'Fri' ]; then modT=3;fi
date +%F -d "+${modT:-1} day"
}
function captains_log() { function captains_log() {
# Take into account only the work week. # Take into account only the work week.
# Might make sense in the future to check if there are any notes for the intervening days Sat/Sun # Might make sense in the future to check if there are any notes for the intervening days Sat/Sun
# and display them if so # and display them if so
if [ "$(date +%a)" == 'Mon' ]; then modY=3;fi YESTERDAY=$(prev_working_day)
if [ "$(date +%a)" == 'Fri' ]; then modT=3;fi TODAY=$(today)
YESTERDAY=$(date +%F -d "-${modY:-1} day") TOMORROW=$(next_working_day)
TODAY=$(date +%F)
TOMORROW=$(date +%F -d "+${modT:-1} day")
if [ ${GIT:-1} ] && (git -C $CLDIR rev-parse 2>/dev/null) ; then if [ ${GIT:-1} ] && (git -C $CLDIR rev-parse 2>/dev/null) ; then
GIT=1 GIT=1
@ -151,6 +165,9 @@ function captains_log() {
if [ ${1-x} == 'x' ]; then if [ ${1-x} == 'x' ]; then
for i in YESTERDAY TODAY TOMORROW; do for i in YESTERDAY TODAY TOMORROW; do
generate_file ${!i} generate_file ${!i}
if [ $i == 'TODAY' ]; then
transfer_items $CLDIR/$YESTERDAY $CLDIR/$TODAY
fi
done done
if [ -f "$CLDIR/backlog" ]; then if [ -f "$CLDIR/backlog" ]; then
vi $CLDIR/{$YESTERDAY,$TODAY,$TOMORROW,backlog} -s <( echo -e ":vsplit\n:wincmd w\n:next\n:vsplit\n:wincmd w\n:next\n:split\n:wincmd w\n:next") vi $CLDIR/{$YESTERDAY,$TODAY,$TOMORROW,backlog} -s <( echo -e ":vsplit\n:wincmd w\n:next\n:vsplit\n:wincmd w\n:next\n:split\n:wincmd w\n:next")
@ -159,11 +176,11 @@ function captains_log() {
fi fi
else else
generate_file $1 generate_file $1
transfer_items $CLDIR/$YESTERDAY $CLDIR/$TODAY
vi $CLDIR/$(date -d "$1" "+%F") vi $CLDIR/$(date -d "$1" "+%F")
fi fi
asset generate_links asset generate_links
if [ $GIT -ne 0 ]; then if [ $GIT -ne 0 ]; then
@ -232,10 +249,6 @@ function generate_file() {
fi fi
} }
function asset_generate_links() { function asset_generate_links() {
# Either do files modified in the last 7 days, or all files # Either do files modified in the last 7 days, or all files
if [ "$1" == "all" ]; then if [ "$1" == "all" ]; then
@ -308,6 +321,34 @@ function asset() {
} }
function transfer_items() {
TRANSFER=''
while read line1;
do while read line2; do
MATCH=0 ;
VAL=$(echo "$(fstrcmp -- "$line1" "$line2") * 100"|bc -l|cut -d . -f1 );
if [ $VAL -gt 60 ]; then
MATCH=1
break
fi;
done < <(grep '^\s*[~-]' $2);
if [ $MATCH -eq 0 ]; then
TRANSFER="${TRANSFER}\n$line1"
fi
done < <(grep '^\s*[~-]' $1)
if [ "$TRANSFER" != '' ]; then
echo -e "\nThese incomeplete/ongoing items have been transferred from $(basename "$1"):\n $TRANSFER" >> $2
fi
}
@ -335,6 +376,7 @@ while [ $1 ]; do
asset) shift; asset "$@"; exit;; asset) shift; asset "$@"; exit;;
*ASSET*) asset "$@"; exit;; *ASSET*) asset "$@"; exit;;
help|--help|-h) help; exit;; help|--help|-h) help; exit;;
transfer) transfer_items $CLDIR/$(today) $CLDIR/$(next_working_day); exit;;
*) break;; *) break;;
esac esac
done done

Loading…
Cancel
Save