From 196023255307da84a1903d9880d5a8167f92d91c Mon Sep 17 00:00:00 2001 From: ayakael Date: Sun, 8 Apr 2018 13:01:55 -0400 Subject: [PATCH] [cmd_update] Made CLI logging prettier --- src/cmd_update | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/cmd_update b/src/cmd_update index 8ac160c..4781826 100644 --- a/src/cmd_update +++ b/src/cmd_update @@ -29,8 +29,12 @@ cmd_update() { local OLD_COMMIT=$(awk 'BEGIN{FS="\t"}{if($1=="LAST_UPDATE"){print $2}}' ${DB_FILE}) local imageidList=($(sed 's/\(.*\)\..*/\1/' <<< $(git -C "${GIT_DIR}" diff --name-only ${NEW_COMMIT} ${OLD_COMMIT}) | awk '!seen[$0]++' | grep SHA256)) - _msg EXEC "Updating database from ${OLD_COMMIT} to ${NEW_COMMIT}" - db_update "${GIT_DIR}" "${TARGET}" "${DB_FILE}" ${imageidList[@]} - [[ $? -ne 0 ]] && { _msg WARN; local ERR=true; } || _msg OK + local COUNT=1 + for imageid in ${imageidList[@]}; do + echo "[ ${COUNT} / ${#imageidList[@]} ] Processing ${imageid}" + db_update "${GIT_DIR}" "${TARGET}" "${DB_FILE}" ${imageid} >${STDERR} 2>&1 + [[ $? -eq 0 ]] || { echo "[>>>>>>] Error reported"; cat ${STDERR}; local ERR=true; } + local COUNT=$(( ${COUNT} + 1 )) + done [[ ${ERR} ]] && return 1 || { gawk -i inplace -v newcommit=${NEW_COMMIT} 'BEGIN{FS="\t";OFS="\t"}{if($1=="LAST_UPDATE"){$2=newcommit}{print $0}}' ${DB_FILE}; return 0; } }