Skip to content

Commit

Permalink
Add command to list apps in a table format, including if they are ins…
Browse files Browse the repository at this point in the history
…talled, enabled, or disabled
  • Loading branch information
CLHatch committed Feb 2, 2025
1 parent 726bda2 commit 2ae1a6c
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
32 changes: 32 additions & 0 deletions .scripts/apps_list.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env bash
set -Eeuo pipefail
IFS=$'\n\t'

apps_list() {
local -a APPS
local APPS=($(run_script 'builtin_apps'))
for index in "${!APPS[@]}"; do
local APPNAME=${APPS[$index]}
APPS[$index]+=','
if run_script 'app_is_installed' ${APPNAME}; then
APPS[$index]+='*INSTALLED*,'
if run_script 'app_is_enabled' ${APPNAME}; then
APPS[$index]+='*ENABLED*'
else
APPS[$index]+='*DISABLED*'
fi
else
APPS[$index]+=','
fi
APPS[$index]+=','
#if run_script 'app_is_depreciated' ${APPNAME}; then
# APPS[$index]+='(DEPRECIATED)'
#fi
done
printf '%s\n' "${APPS[@]}" | column -t -s ','
}

test_apps_list() {
run_script 'apps_list'
# warn "CI does not test apps_list."
}
7 changes: 6 additions & 1 deletion main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ For regular usage you can run without providing any options.
force certain install/upgrade actions to run even if they would not be needed
-l --list
List all apps
--list-builtin
List builtin apps
--list-installed
List installed apps
--list-enabled
Expand Down Expand Up @@ -541,11 +543,14 @@ main() {
exit
fi
if [[ -n ${LIST-} ]]; then
run_script 'builtin_apps'
run_script 'apps_list'
exit
fi
if [[ -n ${LISTMETHOD-} ]]; then
case "${LISTMETHOD-}" in
--list-builtin)
run_script 'builtin_apps'
;;
--list-installed)
run_script 'installed_apps'
;;
Expand Down

0 comments on commit 2ae1a6c

Please sign in to comment.