From 0e9c733b50e8dc3b4605e00f4df549b06f6c0411 Mon Sep 17 00:00:00 2001 From: ayakael Date: Sun, 10 Feb 2019 11:36:06 -0500 Subject: [PATCH] [cmd_update][db_update][parser][help/deploy] Added --include option to export newly added images --- help/deploy | 2 ++ src/cmd_update | 3 ++- src/db_update | 4 +++- src/parser | 7 ++++++- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/help/deploy b/help/deploy index 5c45d29..121b317 100644 --- a/help/deploy +++ b/help/deploy @@ -5,3 +5,5 @@ Deploys tracks to target folder, with applies metadata and cover image Options --from Defines what what commit should dam deploy from. Defaults to when last succesfull deploy occured. + --include + Includes new images in next export diff --git a/src/cmd_update b/src/cmd_update index be459c0..5ef37a0 100644 --- a/src/cmd_update +++ b/src/cmd_update @@ -13,6 +13,7 @@ # } cmd_update() { + [[ "${1}" == "--include" ]] && { local INCLUDE=true; shift; } local GIT_DIR="${1}" local TARGET="${2}" local OLD_COMMIT="${3}" @@ -36,7 +37,7 @@ cmd_update() { local COUNT=1 for imageid in ${imageidList[@]}; do echo "[ ${COUNT} / ${#imageidList[@]} ] Processing ${imageid}" - db_update "${GIT_DIR}" "${TARGET}" "${DB_FILE}" ${imageid} >${STDERR} 2>&1 + db_update $([[ ${INCLUDE} ]] && echo "--include") "${GIT_DIR}" "${TARGET}" "${DB_FILE}" ${imageid} >${STDERR} 2>&1 local EXIT=$? [[ ${EXIT} -eq 0 ]] && { _ansi up 2; echo -en '\033[K'; echo "[ ${COUNT} / ${#imageidList[@]} ] Added ${imageid}"; } [[ ${EXIT} -eq 1 ]] && { _ansi up 2; echo -en '\033[K'; echo "[ ${COUNT} / ${#imageidList[@]} ] Removed ${imageid}"; } diff --git a/src/db_update b/src/db_update index 23b8f1d..59ed7a1 100644 --- a/src/db_update +++ b/src/db_update @@ -11,6 +11,7 @@ # } db_update() { + [[ "${1}" == "--include" ]] && { local INCLUDE=true; shift; } local GIT_DIR="${1}" local TARGET="${2}" local DB_FILE="${3}" @@ -24,7 +25,8 @@ db_update() { fi for trackid in ${trackidList[@]}; do if [[ -z $(awk -v imageid="${IMAGEID}" -v trackid="${trackid}" 'BEGIN{FS="\t"}{if($2==imageid && $3==trackid){print $0}}' ${DB_FILE}) ]]; then - echo -e "false\t${IMAGEID}\t${trackid}\tnull" >> ${DB_FILE} + [[ ${INCLUDE} ]] && echo -en "true" >> ${DB_FILE} || echo -en "false" >> ${DB_FILE} + echo -e "\t${IMAGEID}\t${trackid}\tnull" >> ${DB_FILE} fi done return 0 diff --git a/src/parser b/src/parser index 12baa5d..3c029db 100644 --- a/src/parser +++ b/src/parser @@ -129,6 +129,11 @@ case "${1}" in shift ;; + --include) + INCLUDE=true + shift + ;; + *) TARGET="${1}" shift @@ -136,7 +141,7 @@ case "${1}" in esac done - cmd_update "${_GIT_DIR}" "${TARGET}" "${OLD_COMMIT}" + cmd_update $([[ ${INCLUDE} ]] && echo "--include") "${_GIT_DIR}" "${TARGET}" "${OLD_COMMIT}" EXIT=$? [[ ${EXIT} -eq 0 ]] && echo "Update completed successfully" [[ ${EXIT} -eq 1 ]] && echo "Update completed with errors"