lib/helpers: fix `_bash-it-describe()`

Use `_bash-it-component-item-is-enabled()`

Fix SC2295
pull/1934/head
John D Pell 2022-01-03 16:59:50 -08:00 committed by John D Pell
parent 4c473853e9
commit 550f808884
2 changed files with 10 additions and 14 deletions

View File

@ -689,14 +689,10 @@ _bash-it-determine-component-status-from-path() {
# Check for both the old format without the load priority, and the extended format with the priority # Check for both the old format without the load priority, and the extended format with the priority
local enabled_files enabled_file local enabled_files enabled_file
enabled_file="${f##*/}" enabled_file="${f##*/}"
enabled_file="${enabled_file%.*.bash}" enabled_file="${enabled_file%."${file_type}"*.bash}"
enabled_files=$(sort <(compgen -G "${BASH_IT}/enabled/*$BASH_IT_LOAD_PRIORITY_SEPARATOR${enabled_file}") <(compgen -G "${BASH_IT}/$subdirectory/enabled/${enabled_file}") <(compgen -G "${BASH_IT}/$subdirectory/enabled/*$BASH_IT_LOAD_PRIORITY_SEPARATOR${enabled_file}") | wc -l) enabled=
_bash-it-component-item-is-enabled "${file_type}" "${enabled_file}" && enabled='x'
if [[ "$enabled_files" -gt 0 ]]; then return 0
enabled='x'
else
enabled=' '
fi
} }
function _bash-it-describe() { function _bash-it-describe() {
@ -713,11 +709,11 @@ function _bash-it-describe() {
column_header="$4" column_header="$4"
local f local f
local enabled local enabled enabled_file
printf "%-20s%-10s%s\n" "$column_header" 'Enabled?' 'Description' printf "%-20s %-10s %s\n" "$column_header" 'Enabled?' 'Description'
for f in "${BASH_IT}/$subdirectory/available"/*.bash; do for f in "${BASH_IT?}/$subdirectory/available"/*.*.bash; do
_bash-it-determine-component-status-from-path "$f" _bash-it-determine-component-status-from-path "$f"
printf "%-20s%-10s%s\n" "$enabled_file" " [$enabled]" "$(metafor "about-$file_type" < "$f")" printf "%-20s %-10s %s\n" "$enabled_file" "[${enabled:- }]" "$(metafor "about-$file_type" < "$f")"
done done
printf '\n%s\n' "to enable $preposition $file_type, do:" printf '\n%s\n' "to enable $preposition $file_type, do:"
printf '%s\n' "$ bash-it enable $file_type <$file_type name> [$file_type name]... -or- $ bash-it enable $file_type all" printf '%s\n' "$ bash-it enable $file_type <$file_type name> [$file_type name]... -or- $ bash-it enable $file_type all"
@ -1004,7 +1000,7 @@ function _help-plugins() {
rm "$grouplist" 2> /dev/null rm "$grouplist" 2> /dev/null
} }
_help-profile() { function _help-profile() {
_about 'help message for profile command' _about 'help message for profile command'
_group 'lib' _group 'lib'

View File

@ -732,5 +732,5 @@ function __migrate_all_components() {
@test "helpers: describe the todo.txt-cli aliases without enabling them" { @test "helpers: describe the todo.txt-cli aliases without enabling them" {
run _bash-it-aliases run _bash-it-aliases
assert_line "todo.txt-cli [ ] todo.txt-cli abbreviations" assert_line "todo.txt-cli [ ] todo.txt-cli abbreviations"
} }