Skip to content

Commit

Permalink
upload.*: Add --hide flag
Browse files Browse the repository at this point in the history
This flag will prevent the script to print sensitive information like root folder id or drivelink
  • Loading branch information
Akianonymus committed Jul 26, 2020
1 parent 7e5c8c2 commit 35600cb
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,12 @@ These are the custom flags that are currently implemented:

---

- <strong>--hide</strong>

This flag will prevent the script to print sensitive information like root folder id or drivelink

---

- <strong>-q | --quiet</strong>

Supress the normal output, only show success/error upload messages for files, and one extra line at the beginning for folder showing no. of files and sub folders.
Expand Down
12 changes: 8 additions & 4 deletions bash/upload.bash
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Options:\n
e.g: ${0##*/} local_folder --include "*1*", will only include with files with pattern '1' in the name.\n
-ex | --exclude 'pattern' - Exclude the files with the given pattern from uploading. - Applicable for folder uploads.\n
e.g: ${0##*/} local_folder --exclude "*1*", will exclude all the files pattern '1' in the name.\n
--hide - This flag will prevent the script to print sensitive information like root folder id or drivelink.\n
-v | --verbose - Display detailed message (only for non-parallel uploads).\n
-V | --verbose-progress - Display detailed message and detailed upload progress(only for non-parallel uploads).\n
--skip-internet-check - Do not check for internet connection, recommended to use in sync jobs.\n
Expand Down Expand Up @@ -248,6 +249,7 @@ _setup_arguments() {
_check_longoptions "${1}" "${2}"
EXCLUDE_FILES="${EXCLUDE_FILES} ! -name '${2}' " && shift
;;
--hide) HIDE_INFO=":" ;;
-q | --quiet) QUIET="_print_center_quiet" ;;
-v | --verbose) VERBOSE="true" ;;
-V | --verbose-progress) VERBOSE_PROGRESS="true" && CURL_PROGRESS="" ;;
Expand Down Expand Up @@ -492,9 +494,11 @@ _process_arguments() {
# on successful uploads
_share_and_print_link() {
"${SHARE:-:}" "${1:-}" "${ACCESS_TOKEN}" "${SHARE_EMAIL}"
_print_center "justify" "DriveLink" "${SHARE:+ (SHARED)}" "-"
_is_terminal && [[ ${COLUMNS} -gt 45 ]] && _print_center "normal" "↓ ↓ ↓" ' '
_print_center "normal" "https://drive.google.com/open?id=${1:-}" " "
[[ -z ${HIDE_INFO} ]] &&
_print_center "justify" "DriveLink" "${SHARE:+ (SHARED)}" "-" &&
_is_terminal && [[ ${COLUMNS} -gt 45 ]] && _print_center "normal" "↓ ↓ ↓" ' ' &&
_print_center "normal" "https://drive.google.com/open?id=${1:-}" " "
return 0
}

for input in "${FINAL_LOCAL_INPUT_ARRAY[@]}"; do
Expand Down Expand Up @@ -632,7 +636,7 @@ _process_arguments() {
printf "\n"
else
_clear_line 1
"${QUIET:-_print_center}" "justify" "File ID (${gdrive_id})" " invalid." "=" 1>&2
"${QUIET:-_print_center}" "justify" "File ID (${HIDE_INFO:-gdrive_id})" " invalid." "=" 1>&2
printf "\n"
fi
done
Expand Down
14 changes: 9 additions & 5 deletions sh/upload.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Options:\n
e.g: ${0##*/} local_folder --include "*1*", will only include with files with pattern '1' in the name.\n
-ex | --exclude 'pattern' - Exclude the files with the given pattern from uploading. - Applicable for folder uploads.\n
e.g: ${0##*/} local_folder --exclude "*1*", will exclude all the files pattern '1' in the name.\n
--hide - This flag will prevent the script to print sensitive information like root folder id and drivelink.\n
-v | --verbose - Display detailed message (only for non-parallel uploads).\n
-V | --verbose-progress - Display detailed message and detailed upload progress(only for non-parallel uploads).\n
--skip-internet-check - Do not check for internet connection, recommended to use in sync jobs.\n
Expand Down Expand Up @@ -261,6 +262,7 @@ _setup_arguments() {
_check_longoptions "${1}" "${2}"
EXCLUDE_FILES="${EXCLUDE_FILES} ! -name '${2}' " && shift
;;
--hide) HIDE_INFO=":" ;;
-q | --quiet) QUIET="_print_center_quiet" ;;
-v | --verbose) VERBOSE="true" ;;
-V | --verbose-progress) VERBOSE_PROGRESS="true" && CURL_PROGRESS="" ;;
Expand Down Expand Up @@ -504,9 +506,11 @@ _process_arguments() {
# on successful uploads
_share_and_print_link() {
"${SHARE:-:}" "${1:-}" "${ACCESS_TOKEN}" "${SHARE_EMAIL}"
_print_center "justify" "DriveLink" "${SHARE:+ (SHARED)}" "-"
_is_terminal && [ "$((COLUMNS))" -gt 45 ] 2> /dev/null && _print_center "normal" '^ ^ ^' ' '
_print_center "normal" "https://drive.google.com/open?id=${1:-}" " "
[ -z "${HIDE_INFO}" ] &&
_print_center "justify" "DriveLink" "${SHARE:+ (SHARED)}" "-" &&
_is_terminal && [ "$((COLUMNS))" -gt 45 ] 2> /dev/null && _print_center "normal" '^ ^ ^' ' ' &&
_print_center "normal" "https://drive.google.com/open?id=${1:-}" " "
return 0
}
unset Aseen && while read -r input <&4 &&
Expand Down Expand Up @@ -658,7 +662,7 @@ EOF
printf "\n"
else
_clear_line 1
"${QUIET:-_print_center}" "justify" "File ID (${gdrive_id})" " invalid." "=" 1>&2
"${QUIET:-_print_center}" "justify" "File ID (${HIDE_INFO:-gdrive_id})" " invalid." "=" 1>&2
printf "\n"
fi
done 4<< EOF
Expand Down Expand Up @@ -713,7 +717,7 @@ main() {
{ _setup_workspace && for _ in 1 2; do _clear_line 1; done; } ||
{ "${QUIET:-_print_center}" "normal" "[ Error: Workspace setup failed ]" "=" && exit 1; }
_print_center "justify" "Workspace Folder: ${WORKSPACE_FOLDER_NAME}" "="
_print_center "normal" " ${WORKSPACE_FOLDER_ID} " "-" && _newline "\n"
"${HIDE_INFO:-_print_center}" "normal" " ${WORKSPACE_FOLDER_ID} " "-" && _newline "\n"
_process_arguments
Expand Down

0 comments on commit 35600cb

Please sign in to comment.