Finalize minor bug fixes and format for deployment

This commit is contained in:
Eric Torres 2022-10-01 14:42:36 -07:00
parent 4d29aced79
commit 4ad5938594
3 changed files with 138 additions and 139 deletions

View File

@ -31,7 +31,7 @@ while true; do
case "${1}" in
'-d' | '--dir')
template_dir="${2}"
case "${DIR}" in
case "${template_dir}" in
"")
exit 1
;;
@ -44,7 +44,7 @@ while true; do
;;
--dir=*)
template_dir="${1#*=}"
case "${DIR}" in
case "${template_dir}" in
"")
exit 1
;;
@ -80,7 +80,7 @@ done
# If no target specified
if [[ -z "$1" ]]; then
printf '%s\n' 'Please specify target name'
help
exit 1
fi
@ -90,7 +90,7 @@ if ! [[ -d "$template_dir" ]]; then
exit 2
fi
files="$("${fd_opts[@]}" "$DIR")"
files="$(fd "${fd_opts[@]}" -- . "$template_dir")"
selected_file="$(fzf --select-1 --exit-0 <<< "$files")"
# Check if target exists

View File

@ -108,7 +108,7 @@ elif [[ -z $DIR ]]; then
DIR='.'
fi
files="$(find_files $DIR "${fd_opts[@]}")"
files="$(fd "${fd_opts[@]}" -- . $DIR)"
selected_file="$(fzf --select-1 --exit-0 <<< "$files")"
if [[ -w "${selected_file}" ]]; then

View File

@ -14,6 +14,7 @@ WHITE_BOLD=$'\e[1;37m'
RESET=$'\e[0;0m'
fd_opts=(--hidden --threads "$(nproc)")
rm_opts=(--verbose)
declare -a typeopts
# Helper functions
@ -105,7 +106,7 @@ while true; do
exit 1
;;
esac
fd_opts+=('--extension' "$EXT")
fd_opts+=(--extension "$EXT")
shift 2
continue
;;
@ -119,7 +120,7 @@ while true; do
exit 1
;;
esac
fd_opts+=('--extension' "$EXT")
fd_opts+=(--extension "$EXT")
shift
continue
;;
@ -129,7 +130,7 @@ while true; do
continue
;;
'-F' | '--force-directory-delete')
rm_force='--force'
rm_opts+=(--recursive --force)
shift
continue
;;
@ -167,8 +168,10 @@ while true; do
done
# Interpret options
# If nothing was entered
if [[ -z "$*" ]]; then
help
exit 1
fi
declare -a files pattern_results
@ -195,7 +198,7 @@ for p in "${paths[@]}"; do
done
# Padding between files and prompt
#color_output '' reset
color_output '' reset
read -r -n 1 -p 'Would you like to delete these files? [y/N]: ' user_response
# Padding between prompt and output
@ -203,10 +206,6 @@ echo ''
if [[ "$user_response" =~ (y|Y) ]]; then
for p in "${paths[@]}"; do
if [[ -d "$p" ]]; then
rm --recursive "$rm_force" --verbose -- "$p" || printf '%s %s\n' "$(color_output "Unable to remove path:" 'red')" "$(color_path "$p")"
else
rm "$rm_force" --verbose -- "$p" || printf '%s %s\n' "$(color_output "Unable to remove path:" 'red')" "$(color_path "$p")"
fi
rm "${rm_opts[@]}" -- "$p" || printf '%s %s\n' "$(color_output "Unable to remove path:" 'red')" "$(color_path "$p")"
done
fi