123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532 |
- #!/bin/sh
- ############################################################################################
- # THIS MODULE INCLUDES ALL THE ACTIONS INTENDED FOR THE MANAGEMENT OF LISTS AND SINGLE PAGES
- ############################################################################################
- ################################################################################
- # ABOUT
- ################################################################################
- _about_show_markdown() {
- if curl -o /dev/null -sIf "$markdown_url"; then
- markdown_page=$(curl -Ls "$markdown_url" \
- | sed '1,${ /^\s*#/ d; /^\s*!/ d; /\[Applications]/d; /\ --- /d; /\ | - | /d; /\!\[/d; }' \
- | sed '$!N;s/^\s*\n\s*$//;P;D')
- echo "$markdown_page" | fold -sw 72 | sed 's/^ //g; s/^/ /g'
- elif curl -Ls "$toolpack_readme" | grep -q "^| $arg " || curl -Ls "$toolpack_readme" | grep -q "^| $(echo "$arg" | sed 's/\.toolpack//g') "; then
- toolpack_appname=$(echo "$arg" | sed 's/\.toolpack//g')
- toolpack_md=$(curl -Ls "$toolpack_readme")
- toolpack_arg=$(echo "$toolpack_md" | grep -i "^| $toolpack_appname " | tr '|' '\n' | cut -c 2- | grep .)
- toolpack_about_description=$(echo "$toolpack_arg" | awk -F: "NR==$toolpack_description")
- toolpack_about_site=$(echo "$toolpack_arg" | awk -F: "NR==$toolpack_site")
- printf "\n%b\n\nSOURCE: %b\n" "$toolpack_about_description" "$toolpack_about_site" | fold -sw 72 | sed 's/^ //g; s/^/ /g'
- else
- printf ' "%s" IS NOT A VALID ARGUMENT\n' "$package_name"
- fi
- }
- _about_page() {
- _determine_args
- package_name="${Green}$1\033[0m"
- markdown_url="$AMCATALOGUEMARKDOWNS/${1}.md"
- printf " PACKAGE: %b\n" "$package_name"
- app_name=$(echo "$1" | sed 's/-appimage//g; s/debian-testing-//g; s/\.toolpack//g; s/\.dwfs.appbundle//g; s/\.appbundle//g')
- argpath=$(echo "$ARGPATHS" | grep "/$app_name$")
- if [ -f "$argpath/remove" ]; then
- app_status="installed\033[0m"
- if test -f "$argpath"/.am-installer/*; then
- scriptname=$(basename -- "$(find "$argpath"/.am-installer/* | head -1)")
- if [ "$app_name" != "$scriptname" ]; then
- app_status="installed\033[0m, but replaced by ${Green}$scriptname\033[0m\n\n NOTE: run ${RED}$AMCLI -a $scriptname\033[0m instead"
- fi
- if test -f "$argpath"/.am-installer/"$arg" && [ "$arg" != "$app_name" ]; then
- app_status="installed\033[0m, as ${Green}$app_name\033[0m"
- fi
- elif [ "$arg" != "$app_name" ]; then
- app_status="not installed"
- fi
- else
- app_status="not installed"
- fi
- METAPACKAGES="kdegames kdeutils node platform-tools"
- for m in $METAPACKAGES; do
- metaargpath=$(echo "$ARGPATHS" | grep "/$m$")
- if grep -q "◆ $1 : .*\"$m\"" "$AMDATADIR/$ARCH-apps"; then
- if test -f "$metaargpath/remove"; then
- app_status="installed\033[0m, as part of ${Green}$m\033[0m\n\n NOTE: run ${RED}$AMCLI -a $m\033[0m instead"
- app_name="$m"
- fi
- elif [ "$1" = "$m" ]; then
- app_status="installed\033[0m"
- fi
- done
- if echo "$app_status" | grep -q "^installed"; then
- printf " STATUS: %b\n" "${LightBlue}$app_status"
- disk_usage=$(du -sm "$argpath" | cut -f1)
- [ -z "$disk_usage" ] && disk_usage=$(du -sm "$metaargpath" | cut -f1)
- app_version=$(grep -w " ◆ $app_name |" "$AMCACHEDIR"/version-args 2>/dev/null | sed 's:.*| ::')
- echo ""
- echo " Disk usage: $disk_usage MB"
- echo " Installed version: $app_version"
- else
- echo " STATUS: $app_status"
- fi
- _about_show_markdown
- }
- ################################################################################
- # FILES
- ################################################################################
- _files_header() {
- CHECK_TOOLPACK="$(find "$APPSPATH"/*/* -type f -name '*.toolpack' -print -quit 2>/dev/null)"
- echo ""
- APPSNUMB=$(find "$APPSPATH" -type f -name 'remove' -exec grep -L 'usr/local/lib' {} \; 2>/dev/null | sed -r 's|/[^/]+$||' | sort | uniq | wc -l)
- if [ "$APPSNUMB" = 1 ]; then
- APPSMESSAGE="YOU HAVE INSTALLED $APPSNUMB PROGRAM"
- else
- APPSMESSAGE="YOU HAVE INSTALLED $APPSNUMB PROGRAMS"
- fi
- if grep -q 'usr/local/lib' "$APPSPATH"/*/remove 2> /dev/null; then
- LIBNUMB=$(grep -l "usr/local/lib" "$APPSPATH"/*/remove | wc -l)
- if [ "$LIBNUMB" = 1 ]; then
- LIBSMESSAGE="AND $LIBNUMB LIBRARY"
- else
- LIBSMESSAGE="AND $LIBNUMB LIBRARIES"
- fi
- [ "$APPMAN_ON" = 1 ] && echo "- $APPSMESSAGE $LIBSMESSAGE LOCALLY, AS \"APPMAN\"" || echo "- $APPSMESSAGE $LIBSMESSAGE MANAGED BY \"$AMCLIUPPER\""
- else
- [ "$APPMAN_ON" = 1 ] && echo "- $APPSMESSAGE LOCALLY, AS \"APPMAN\"" || echo "- $APPSMESSAGE MANAGED BY \"$AMCLIUPPER\""
- fi
- echo ""
- if [ -n "$CHECK_TOOLPACK" ]; then
- files_table_header="- APPNAME | DB | VERSION | TYPE | SIZE "
- files_table_header_lines="- ------- | -- | ------- | ---- | ----"
- else
- files_table_header="- APPNAME | VERSION | TYPE | SIZE "
- files_table_header_lines="- ------- | ------- | ---- | ----"
- fi
- }
- # Functions to determine file's type
- _files_if_binary() {
- if file ./"$arg"/* | grep "static" >/dev/null 2>&1; then
- echo " ◆ $arg | static-binary" >> "$AMCACHEDIR"/files-type
- else
- echo " ◆ $arg | dynamic-binary" >> "$AMCACHEDIR"/files-type
- fi
- }
- _files_if_library() {
- echo " ◆ $arg | library" >> "$AMCACHEDIR"/files-type
- }
- _files_if_script() {
- if grep "/ffwa" "${LINK:-$FILE}" >/dev/null 2>&1; then
- echo " ◆ $arg | launcher" >> "$AMCACHEDIR"/files-type
- elif grep '#!.*bash' "${LINK:-$FILE}" >/dev/null 2>&1; then
- echo " ◆ $arg | bash-script" >> "$AMCACHEDIR"/files-type
- elif grep '#!.*dash' "${LINK:-$FILE}" >/dev/null 2>&1; then
- echo " ◆ $arg | dash-script" >> "$AMCACHEDIR"/files-type
- elif grep '#!.*bin.*sh' "${LINK:-$FILE}" >/dev/null 2>&1; then
- echo " ◆ $arg | posix-script" >> "$AMCACHEDIR"/files-type
- elif grep '#!.*awk' "${LINK:-$FILE}" >/dev/null 2>&1; then
- echo " ◆ $arg | awk-script" >> "$AMCACHEDIR"/files-type
- else
- echo " ◆ $arg | script" >> "$AMCACHEDIR"/files-type
- fi
- }
- _files_if_appimage() {
- if ! echo "$string" | grep 'AppImages require FUSE to run' >/dev/null 2>&1; then
- if grep "SANDBOXDIR" "$FILE" >/dev/null 2>&1; then
- echo " ◆ $arg | appimage🔒" >> "$AMCACHEDIR"/files-type
- else
- echo " ◆ $arg | appimage" >> "$AMCACHEDIR"/files-type
- fi
- else
- if grep "SANDBOXDIR" "$FILE" >/dev/null 2>&1; then
- echo " ◆ $arg | appimage🔒*" >> "$AMCACHEDIR"/files-type
- else
- echo " ◆ $arg | appimage*" >> "$AMCACHEDIR"/files-type
- fi
- fi
- }
- _files_type() {
- APPVERSION=$(<"$AMCACHEDIR"/version-args grep -w " ◆ $arg |" | sed 's:.*| ::')
- string=$(strings -d ./"$arg/$arg" 2>/dev/null)
- FILE=$(command -v "$arg" 2>/dev/null)
- LINK=$(readlink "$FILE" 2>/dev/null)
- if echo "$string" | grep -- '--appimage-extract option' >/dev/null 2>&1; then
- _files_if_appimage
- elif file ./"$arg"/* | grep -E 'LSB|/bin' >/dev/null 2>&1; then
- _files_if_binary
- elif grep "#!" "${LINK:-$FILE}" >/dev/null 2>&1; then
- _files_if_script
- elif grep "usr/local/lib" ./"$arg"/remove >/dev/null 2>&1; then
- _files_if_library
- else
- echo " ◆ $arg | other" >> "$AMCACHEDIR"/files-type
- fi
- }
- # Function to determine file's size
- _files_sizes() {
- if grep -q "usr/local/lib" ./"$arg"/remove; then
- LIBNAME=$(<"$APPSPATH"/"$arg"/remove tr ' ' '\n' | grep "usr/local/lib" | head -1 | sed 's/*//g')
- SIZE=$(du -sh "$LIBNAME"* | cut -f1 | sort -rh | head -1)
- else
- SIZE=$(du -sh -- "$arg" | cut -f1 -d" ")
- fi
- SIZE=$(echo "$SIZE" | sed 's/.$/ &/; s/$/iB/')
- echo " ◆ $arg | $SIZE" >> "$AMCACHEDIR"/files-sizes
- }
- # Function to determine file's database
- _files_db() {
- if test -f "$APPSPATH"/"$arg"/.am-installer/*toolpack; then
- DB="toolpacks"
- elif [ "$arg" = am ]; then
- DB="am"
- elif test -f "$CACHEDIR"/extra/"$arg" || test -f "$APPSPATH"/"$arg"/.am-installer/"$arg" && ! grep -q "^APP=" "$APPSPATH"/"$arg"/.am-installer/"$arg"; then
- DB="none"
- elif test -f "$AMDATADIR/$ARCH-apps" && ! grep -q "^◆ $arg :" "$AMDATADIR/$ARCH-apps"; then
- DB="unknown"
- else
- DB="am"
- fi
- echo " ◆ $arg | $DB" >> "$AMCACHEDIR"/files-db
- }
- # Functions to create file's table
- _files_files() {
- cd "$APPSPATH" || exit 1
- INSTALLED_APPS=$(find . -name 'remove' -printf "%h\n" 2>/dev/null | du -sh -- * 2> /dev/null | sort -rh | sed 's@.* @@')
- if ! test -f "$AMCACHEDIR"/version-args; then
- _check_version
- fi
- if ! test -f "$AMCACHEDIR"/files-type; then
- for arg in $INSTALLED_APPS; do
- if test -f ./"$arg"/remove 2>/dev/null; then
- _files_type
- fi
- done
- fi
- rm -f "$AMCACHEDIR"/files-sizes "$AMCACHEDIR"/files-db
- for arg in $INSTALLED_APPS; do
- if test -f ./"$arg"/remove 2>/dev/null; then
- _files_sizes
- _files_db
- fi
- done
- }
- _files() {
- _files_files
- rm -f "$AMCACHEDIR"/files-args
- INSTALLED_APPS=$(find . -name 'remove' -printf "%h\n" 2>/dev/null | du -sh -- * 2>/dev/null | sort -rh | sed 's@.* @@')
- for arg in $INSTALLED_APPS; do
- if test -f ./"$arg"/remove 2>/dev/null; then
- APPVERSION=$(grep -w " ◆ $arg |" "$AMCACHEDIR"/version-args | tr ' ' '\n' | tail -1)
- APPTYPE=$(grep -w " ◆ $arg |" "$AMCACHEDIR"/files-type | tr ' ' '\n' | tail -1)
- APPSYZE=$(grep -w " ◆ $arg |" "$AMCACHEDIR"/files-sizes | tr ' ' '\n' | tail -1)
- APPDB=$(grep -w " ◆ $arg |" "$AMCACHEDIR"/files-db | tr ' ' '\n' | tail -1)
- if [ -n "$CHECK_TOOLPACK" ]; then
- echo " ◆ $arg | $APPDB | $APPVERSION | $APPTYPE | $APPSYZE" >> "$AMCACHEDIR"/files-args
- else
- echo " ◆ $arg | $APPVERSION | $APPTYPE | $APPSYZE" >> "$AMCACHEDIR"/files-args
- fi
- fi
- done
- }
- _files_number() {
- FILES_NUMBER=$(find "$APPSPATH" -type f -name 'remove' 2>/dev/null | uniq | wc -l)
- }
- _files_appimage_type_notes() {
- if grep -qe "appimage\*\|appimage🔒\*" "$AMCACHEDIR"/files*; then
- printf " *has dependency to EOL libfuse2 library, please ask the creator to update\n"
- printf "\n"
- fi
- }
- _files_total_size() {
- printf "\n"
- command -v aisap >/dev/null 2>&1 && printf '%s\n\n' " AppImages with 🔒 are sandboxed with aisap"
- echo " TOTAL SIZE: $(find . -type f -name 'remove' -printf "%h\n" | du -ch -- */ 2>/dev/null | awk 'END {print $1"iB"}' | sed 's/...$/ &/') of disk space in use"
- printf "\n"
- }
- _files_sort_by_name() {
- _files_header
- rm -f "$AMCACHEDIR"/files-args-byname
- _files
- echo "$files_table_header" > "$AMCACHEDIR"/files-args-byname
- echo "$files_table_header_lines" >> "$AMCACHEDIR"/files-args-byname
- sort "$AMCACHEDIR"/files-args 2>/dev/null >> "$AMCACHEDIR"/files-args-byname
- column -t "$AMCACHEDIR"/files-args-byname
- _files_total_size
- _files_appimage_type_notes
- }
- _files_sort_by_size() {
- _files_header
- rm -f "$AMCACHEDIR"/files-args-bysize
- _files
- echo "$files_table_header" > "$AMCACHEDIR"/files-args-bysize
- echo "$files_table_header_lines" >> "$AMCACHEDIR"/files-args-bysize
- cat "$AMCACHEDIR"/files-args >> "$AMCACHEDIR"/files-args-bysize 2>/dev/null
- column -t "$AMCACHEDIR"/files-args-bysize
- _files_total_size
- _files_appimage_type_notes
- }
- ################################################################################
- # LIST/QUERY
- ################################################################################
- _pretty_list() {
- # Remove references to URLs, "-a" elements in "-l" and "-q"
- sed -E 's#(http|https|ftp)://[^ ]*##g; s#(SITE|SOURCE):##g; s/^/\n/g' | _colors | fold -sw 75 | sed 's/^/ /g; s/ ◆ /◆ /g; s/ :/ :/g'
- }
- _pretty_list_compat() {
- # Remove references to URLs, "-a" elements in "-l" and "-q"
- sed -E 's#(http|https|ftp)://[^ ]*##g; s#(SITE|SOURCE):##g' | _colors | fold -sw 75 | sed 's/^/ /g; s/ ◆ /◆ /g; s/ :/ :/g'
- }
- _colors() {
- awk '{
- printf "%s \033[32m%s\033[0m", $1, $2
- {$1 = ""; $2 = ""; print $0;}
- }'
- }
- _list() {
- # Check if github.com is online, if not, the function will read the offline list
- wget -q --tries=10 --timeout=20 --spider https://github.com && _completion_lists
- # Check the number of installed apps and libraries
- LIBNUMBER=$(grep "usr/local/lib" "$APPSPATH"/*/remove 2> /dev/null | wc -l)
- ITEMSNUMBER=$(find "$APPSPATH" -name 'remove' -printf "%h\n" 2>/dev/null | sort -u | wc -l)
- _detect_appman_apps
- if [ "$AMCLI" = am ]; then
- if [ -d "$APPMAN_APPSPATH" ]; then
- APPMAN_ITEMS=$(find "$APPMAN_APPSPATH" -name 'remove' -printf "%h\n" 2>/dev/null | sort -u | wc -l)
- ITEMSNUMBER=$(("$ITEMSNUMBER"+"$APPMAN_ITEMS"))
- fi
- if test -f /opt/am/remove; then
- ITEMSNUMBER=$(("$ITEMSNUMBER"-1))
- fi
- fi
- APPSNUMBER=$(("$ITEMSNUMBER" - "$LIBNUMBER"))
- # Determine the number of available apps from the list
- AVAILABLE_APPS_NUMBER=$(grep -v "ffwa-\|\"kdegames\"\|\"kdeutils\"\|\"node\"\|\"platform-tools\"" "$AMDATADIR/$ARCH-apps" | grep -e "$" -c)
- if ! test -f "$AMDATADIR/$ARCH-appimages"; then
- _online_check
- _sync_appimages_list
- AVAILABLE_APPIMAGES_NUMBER=$(grep -e "$" -c "$AMDATADIR/$ARCH-appimages")
- else
- AVAILABLE_APPIMAGES_NUMBER=$(grep -e "$" -c "$AMDATADIR/$ARCH-appimages")
- fi
- if ! test -f "$AMDATADIR/$ARCH-toolpack"; then
- _online_check
- _sync_toolpacks_list
- AVAILABLE_TOOLPACKS_NUMBER=$(grep -e "$" -c "$AMDATADIR/$ARCH-toolpack")
- else
- AVAILABLE_TOOLPACKS_NUMBER=$(grep -e "$" -c "$AMDATADIR/$ARCH-toolpack")
- fi
- [ -n "$AVAILABLE_TOOLPACKS_NUMBER" ] && AVAILABLE_TOTAL_APPS_NUMBER=$(("$AVAILABLE_APPS_NUMBER" + "$AVAILABLE_TOOLPACKS_NUMBER"))
- # Generate a list of the installed apps with version
- [ ! -f "$AMCACHEDIR"/version-args ] && _check_version
- if [ -n "$APPMAN_ITEMS" ]; then
- _check_version
- else
- grep " ◆ $ARGS " "$AMCACHEDIR"/version-args > "$AMCACHEDIR"/version-args-real
- sort "$AMCACHEDIR"/version-args-real > "$AMCACHEDIR"/version-args
- fi
- INSTALLED=$(sort "$AMCACHEDIR"/version-args 2>/dev/null | sed 's/ | / /g' | grep -v "◆ am " | uniq)
- MESSAGE2="$INSTALLED"
- # Check if among the installed apps are available libraries
- if [ "$LIBNUMBER" != 0 ]; then
- # Check if the installed libraries are more than one
- if [ "$LIBNUMBER" = 1 ]; then
- MESSAGE=" YOU HAVE INSTALLED $APPSNUMBER PROGRAMS OUT OF $AVAILABLE_TOTAL_APPS_NUMBER AVAILABLE, AND $LIBNUMBER LIBRARY"
- else
- MESSAGE=" YOU HAVE INSTALLED $APPSNUMBER PROGRAMS OUT OF $AVAILABLE_TOTAL_APPS_NUMBER AVAILABLE, AND $LIBNUMBER LIBRARIES"
- fi
- else
- MESSAGE=" YOU HAVE INSTALLED $APPSNUMBER PROGRAMS OUT OF $AVAILABLE_TOTAL_APPS_NUMBER AVAILABLE"
- fi
- }
- _list_appimages() {
- wget -q --tries=10 --timeout=20 --spider https://github.com && _sync_appimages_list
- if ! test -f "$AMDATADIR/$ARCH-appimages"; then
- _online_check
- _sync_appimages_list
- fi
- }
- _list_toolpacks() {
- wget -q --tries=10 --timeout=20 --spider https://github.com && _sync_toolpacks_list
- if ! test -f "$AMDATADIR/$ARCH-toolpack"; then
- _online_check
- _sync_toolpacks_list
- fi
- }
- _list_msg_head() {
- echo "" && echo "$MESSAGE" && echo "" && echo "$MESSAGE2" && echo ""
- }
- _list_msg_suggest_all() {
- printf "\n To list all installable programs, use the \"%b--all\033[0m\" flag\n" "${LightBlue}"
- }
- _list_msg_footer() {
- echo "$LIST" && echo ""
- }
- _list_toolpacks_msg() {
- _list_msg_head
- echo " LIST OF THE $AVAILABLE_TOOLPACKS_NUMBER PROGRAMS AVAILABLE IN THE \"TOOLPACKS\" DATABASE:"
- _list_msg_suggest_all
- _list_msg_footer
- }
- _list_appimages_msg() {
- _list_msg_head
- echo " LIST OF THE $AVAILABLE_APPIMAGES_NUMBER APPIMAGES AVAILABLE IN THE \"AM\" DATABASE:"
- _list_msg_suggest_all
- _list_msg_footer
- }
- _list_apps_msg() {
- _list_msg_head
- echo " LIST OF THE $AVAILABLE_APPS_NUMBER PROGRAMS AVAILABLE IN THE \"AM\" DATABASE:"
- _list_msg_suggest_all
- _list_msg_footer
- }
- _list_apps_all_msg() {
- _list_msg_head
- echo " LIST OF THE $AVAILABLE_TOTAL_APPS_NUMBER PROGRAMS AVAILABLE IN ALL SUPPORTED DATABASES:"
- _list_msg_footer
- }
- ################################################################################
- # USAGE
- ################################################################################
- case "$1" in
- '-a'|'about')
- [ -z "$2" ] && echo " USAGE: $AMCLI $1 [ARGUMENT]" && exit 1
- _online_check
- printf "%s\n" "-----------------------------------------------------------------------"
- [ ! -f "$AMCACHEDIR"/version-args ] && _check_version
- entries="$(echo "$@" | cut -f2- -d ' ')" # Removes first argument
- for arg in $entries; do
- if curl -o /dev/null -sIf "$AMCATALOGUEMARKDOWNS/${arg}.md" 1>/dev/null; then
- _about_page "$arg"
- elif curl -Ls "$toolpack_readme" | grep -q "^| $arg "; then
- arg="$arg.toolpack"
- _about_page "$arg"
- elif echo "$arg" | grep -q ".toolpack$"; then
- _about_page "$arg"
- else
- printf " ERROR: %b not found\033[0m\n" "${RED}\"$arg\""
- fi
- printf "%s\n" "-----------------------------------------------------------------------"
- done
- ;;
- '-f'|'files')
- if [ "$2" = "--less" ]; then
- _files_number && echo "$FILES_NUMBER"
- [ "$AMCLI" = am ] && [ -f "$APPMANCONFIG"/appman-config ] && _appman && echo "$DIVIDING_LINE" && _files_number && echo "$FILES_NUMBER"
- elif [ "$2" = "--byname" ]; then
- _files_sort_by_name
- [ "$AMCLI" = am ] && [ -f "$APPMANCONFIG"/appman-config ] && _appman && APPMAN_ON=1 && _files_number && [ "$FILES_NUMBER" != 0 ] && echo "$DIVIDING_LINE" && _files_sort_by_name
- _betatester_message_on
- else
- _files_sort_by_size
- [ "$AMCLI" = am ] && [ -f "$APPMANCONFIG"/appman-config ] && _appman && APPMAN_ON=1 && _files_number && [ "$FILES_NUMBER" != 0 ] && echo "$DIVIDING_LINE" && _files_sort_by_size
- _betatester_message_on
- fi
- ;;
- '-l'|'list')
- _list
- if [ "$2" = --all ]; then
- _list_toolpacks
- LIST=$(sort "$AMDATADIR/$ARCH-apps" "$AMDATADIR/$ARCH-toolpack" | uniq | _pretty_list)
- _list_apps_all_msg | less -Ir
- echo "$DIVIDING_LINE"
- echo " $(("$AVAILABLE_APPS_NUMBER" + "$AVAILABLE_TOOLPACKS_NUMBER")) programs in all supported databases"
- echo "$DIVIDING_LINE"
- elif [ "$2" = --appimages ]; then
- _list_appimages
- LIST=$(sort "$AMDATADIR/$ARCH-appimages" | _pretty_list)
- _list_appimages_msg | less -Ir
- echo "$DIVIDING_LINE"
- echo " $AVAILABLE_APPIMAGES_NUMBER AppImages in the \"AM\" database"
- echo "$DIVIDING_LINE"
- elif [ "$2" = --toolpack ]; then
- _list_toolpacks
- LIST=$(sort "$AMDATADIR/$ARCH-toolpack" | _pretty_list)
- _list_toolpacks_msg | less -Ir
- echo "$DIVIDING_LINE"
- echo " $AVAILABLE_TOOLPACKS_NUMBER programs in the \"Toolpacks\" database"
- echo "$DIVIDING_LINE"
- else
- LIST=$(sort "$AMDATADIR/$ARCH-apps" | _pretty_list)
- _list_apps_msg | less -Ir
- echo "$DIVIDING_LINE"
- echo " $AVAILABLE_APPS_NUMBER programs in the \"AM\" database"
- echo "$DIVIDING_LINE"
- fi
- ;;
- '-q'|'query')
- if [ -z "$2" ]; then
- echo " USAGE: $AMCLI $1 [ARGUMENT]"
- echo " $AMCLI $1 --all [ARGUMENT]"
- echo " $AMCLI $1 --appimages [ARGUMENT]"
- echo " $AMCLI $1 --pkg [ARGUMENT]"
- echo " $AMCLI $1 --toolpack [ARGUMENT]"; exit 1
- fi
- wget -q --tries=10 --timeout=20 --spider https://github.com && _completion_lists
- if [ "$2" = --pkg ]; then
- entries="$(echo "$@" | cut -f3- -d ' ' | tr -s ' ' '|')"
- printf "\n Search results for packages: %s\n\n" "$entries" | tr '[:lower:]' '[:upper:]'
- grep -iE "$entries" "$AMDATADIR/$ARCH-apps" --color=always | _pretty_list_compat
- [ -f "$AMDATADIR/$ARCH-toolpack" ] && grep -iE "$entries" "$AMDATADIR/$ARCH-toolpack" --color=always | _pretty_list_compat
- elif [ "$2" = --appimages ]; then
- entries="$(echo "$@" | cut -f3- -d ' ')"
- printf "\n Search results for \"%s\":\n\n" "$entries" | tr '[:lower:]' '[:upper:]'
- pattern="$(echo "$entries" | sed 's/ /(?=.*/g; s/$/)/g; s/(/)(/g; s/^/(?=.*/g;')"
- _list_appimages
- grep -Pi "$pattern" "$AMDATADIR/$ARCH-appimages" | _pretty_list_compat
- elif [ "$2" = --toolpack ]; then
- entries="$(echo "$@" | cut -f3- -d ' ')"
- printf "\n Search results for \"%s\":\n\n" "$entries" | tr '[:lower:]' '[:upper:]'
- pattern="$(echo "$entries" | sed 's/ /(?=.*/g; s/$/)/g; s/(/)(/g; s/^/(?=.*/g;')"
- _list_toolpacks
- grep -Pi "$pattern" "$AMDATADIR/$ARCH-toolpack" | _pretty_list_compat
- elif [ "$2" = --all ]; then
- entries="$(echo "$@" | cut -f3- -d ' ')"
- printf "\n Search results for \"%s\":\n\n" "$entries" | tr '[:lower:]' '[:upper:]'
- pattern="$(echo "$entries" | sed 's/ /(?=.*/g; s/$/)/g; s/(/)(/g; s/^/(?=.*/g;')"
- _list_toolpacks
- sort "$AMDATADIR/$ARCH-toolpack" "$AMDATADIR/$ARCH-apps" | grep -Pi "$pattern" | _pretty_list_compat
- else
- entries="$(echo "$@" | cut -f2- -d ' ')"
- printf "\n Search results for \"%s\":\n\n" "$entries" | tr '[:lower:]' '[:upper:]'
- pattern="$(echo "$entries" | sed 's/ /(?=.*/g; s/$/)/g; s/(/)(/g; s/^/(?=.*/g;')"
- grep -Pi "$pattern" "$AMDATADIR/$ARCH-apps" | _pretty_list_compat
- fi
- printf '\n'
- ;;
- esac
|