mirror of
https://github.com/eth-p/bat-extras.git
synced 2025-06-20 19:57:46 +02:00
Fixed prettybat formatter mappings
This commit is contained in:
parent
6f3cc53bda
commit
5f248064e0
@ -16,7 +16,7 @@ PROGRAM="$0"
|
|||||||
# Formatters:
|
# Formatters:
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
|
|
||||||
FORMATTERS=("prettier" "rustfmt")
|
FORMATTERS=("prettier" "rustfmt" "shfmt")
|
||||||
|
|
||||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
||||||
@ -52,6 +52,19 @@ formatter_rustfmt_process() {
|
|||||||
return $?
|
return $?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
||||||
|
formatter_shfmt_supports() {
|
||||||
|
[[ "$1" = ".sh" ]]
|
||||||
|
return $?
|
||||||
|
}
|
||||||
|
|
||||||
|
formatter_shfmt_process() {
|
||||||
|
shfmt
|
||||||
|
return $?
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
# Functions:
|
# Functions:
|
||||||
@ -115,15 +128,21 @@ print_file() {
|
|||||||
process_file() {
|
process_file() {
|
||||||
local file="$1"
|
local file="$1"
|
||||||
local ext="$2"
|
local ext="$2"
|
||||||
|
local fext="$ext"
|
||||||
local lang="${ext:1}"
|
local lang="${ext:1}"
|
||||||
|
|
||||||
if [[ -n "$OPT_LANGUAGE" ]]; then
|
if [[ -n "$OPT_LANGUAGE" ]]; then
|
||||||
lang="$OPT_LANGUAGE"
|
lang="$OPT_LANGUAGE"
|
||||||
|
fext="$(map_language_to_extension "$lang")"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local formatter="$(map_extension_to_formatter "$ext")"
|
local formatter="$(map_extension_to_formatter "$fext")"
|
||||||
if [[ "$formatter" = "none" ]]; then
|
if [[ "$formatter" = "none" ]]; then
|
||||||
print_file "$file"
|
if [[ -z "$OPT_LANGUAGE" ]]; then
|
||||||
|
print_file "$file"
|
||||||
|
else
|
||||||
|
print_file --language="$OPT_LANGUAGE" "$file"
|
||||||
|
fi
|
||||||
return $?
|
return $?
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -164,9 +183,9 @@ while shiftopt; do
|
|||||||
case "$OPT" in
|
case "$OPT" in
|
||||||
|
|
||||||
# Language Options
|
# Language Options
|
||||||
-l) OPT_LANGUAGE="${OPT_VAL}" ;;
|
-l) shiftval; OPT_LANGUAGE="${OPT_VAL}" ;;
|
||||||
-l*) OPT_LANGUAGE="${OPT:2}" ;;
|
-l*) OPT_LANGUAGE="${OPT:2}" ;;
|
||||||
--language) OPT_LANGUAGE="$OPT_VAL" ;;
|
--language) shiftval; OPT_LANGUAGE="$OPT_VAL" ;;
|
||||||
|
|
||||||
# Bat Options
|
# Bat Options
|
||||||
-*) {
|
-*) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user