Fixed prettybat formatter mappings

This commit is contained in:
Ethan P 2019-06-21 16:17:20 -07:00
parent 6f3cc53bda
commit 5f248064e0
No known key found for this signature in database
GPG Key ID: 1F8DF8091CD46FBC

View File

@ -16,7 +16,7 @@ PROGRAM="$0"
# Formatters:
# -----------------------------------------------------------------------------
FORMATTERS=("prettier" "rustfmt")
FORMATTERS=("prettier" "rustfmt" "shfmt")
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -52,6 +52,19 @@ formatter_rustfmt_process() {
return $?
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
formatter_shfmt_supports() {
[[ "$1" = ".sh" ]]
return $?
}
formatter_shfmt_process() {
shfmt
return $?
}
# -----------------------------------------------------------------------------
# Functions:
@ -115,15 +128,21 @@ print_file() {
process_file() {
local file="$1"
local ext="$2"
local fext="$ext"
local lang="${ext:1}"
if [[ -n "$OPT_LANGUAGE" ]]; then
lang="$OPT_LANGUAGE"
fext="$(map_language_to_extension "$lang")"
fi
local formatter="$(map_extension_to_formatter "$ext")"
local formatter="$(map_extension_to_formatter "$fext")"
if [[ "$formatter" = "none" ]]; then
print_file "$file"
if [[ -z "$OPT_LANGUAGE" ]]; then
print_file "$file"
else
print_file --language="$OPT_LANGUAGE" "$file"
fi
return $?
fi
@ -164,9 +183,9 @@ while shiftopt; do
case "$OPT" in
# Language Options
-l) OPT_LANGUAGE="${OPT_VAL}" ;;
-l*) OPT_LANGUAGE="${OPT:2}" ;;
--language) OPT_LANGUAGE="$OPT_VAL" ;;
-l) shiftval; OPT_LANGUAGE="${OPT_VAL}" ;;
-l*) OPT_LANGUAGE="${OPT:2}" ;;
--language) shiftval; OPT_LANGUAGE="$OPT_VAL" ;;
# Bat Options
-*) {