refactor: include show_os_info() in specify release/edition errors

This commit is contained in:
Martin Wimpress 2024-05-09 15:54:40 +01:00 committed by Martin Wimpress
parent aa285f0f6e
commit 4b70a341a9
1 changed files with 15 additions and 20 deletions

View File

@ -119,11 +119,11 @@ function os_info() {
} }
function show_os_info() { function show_os_info() {
echo
echo -e "$(os_info "${1}" | cut -d'|' -f 1)" echo -e "$(os_info "${1}" | cut -d'|' -f 1)"
echo -e " - Credentials:\t$(os_info "${1}" | cut -d'|' -f 2)" echo -e " - Credentials:\t$(os_info "${1}" | cut -d'|' -f 2)"
echo -e " - Website:\t$(os_info "${1}" | cut -d'|' -f 3)" echo -e " - Website:\t$(os_info "${1}" | cut -d'|' -f 3)"
echo -e " - Description:\t$(os_info "${1}" | cut -d'|' -f 4)" echo -e " - Description:\t$(os_info "${1}" | cut -d'|' -f 4)"
echo
} }
function pretty_name() { function pretty_name() {
@ -152,45 +152,40 @@ function os_supported() {
} }
function error_specify_release() { function error_specify_release() {
echo "ERROR! You must specify a release." show_os_info "${OS}"
case ${OS} in case ${OS} in
*ubuntu-server*) *ubuntu-server*)
echo -n ' - Releases: ' echo -en " - Releases:\t"
releases_ubuntu-server | sed -Ee 's/eol-\S+//g' # hide eol releases releases_ubuntu-server | sed -Ee 's/eol-\S+//g' # hide eol releases
;; ;;
*ubuntu*) *ubuntu*)
echo -n ' - Releases: ' echo -en " - Releases:\t"
releases_ubuntu | sed -Ee 's/eol-\S+//g' # hide eol releases releases_ubuntu | sed -Ee 's/eol-\S+//g' # hide eol releases
;; ;;
*windows*) *windows*)
echo -n ' - Releases: ' echo -en " - Releases:\t"
"releases_${OS}" "releases_${OS}"
echo -n ' - Languages: ' echo -en " - Languages:\t"
"languages_${OS}" && echo "${LANGS[@]}" "languages_${OS}"
echo "${LANGS[@]}"
;; ;;
*) *)
echo -n ' - Releases: ' echo -en " - Releases:\t"
"releases_${OS}" | fold -s -w "$(tput cols)" "releases_${OS}" | fold -s -w "$(tput cols)"
if [[ $(type -t "editions_${OS}") == function ]]; then if [[ $(type -t "editions_${OS}") == function ]]; then
echo -n ' - Editions: ' echo -en " - Editions:\t"
"editions_${OS}" | fold -s -w "$(tput cols)" "editions_${OS}" | fold -s -w "$(tput cols)"
fi fi
;; ;;
esac esac
echo -e "\nERROR! You must specify a release."
exit 1 exit 1
} }
function error_specify_edition() { function error_specify_edition() {
echo -en "ERROR! You must specify an edition.\n - Editions: " show_os_info "${OS}"
#TODO ERROR here echo -e " - Editions:\t$("editions_${OS}" | fold -s -w "$(tput cols)")"
"editions_${OS}" echo -e "\nERROR! You must specify an edition."
exit 1
}
#TODO: Not yet used!
function error_specify_path() {
echo "ERROR! You must specify path."
error_specify_os
exit 1 exit 1
} }
@ -3418,7 +3413,7 @@ Arguments:
--download <os> <release> [edition] : Download image; no VM configuration --download <os> <release> [edition] : Download image; no VM configuration
--create-config <os> [path/url] : Create VM config for a OS image --create-config <os> [path/url] : Create VM config for a OS image
--open-homepage <os> : Open homepage for the OS --open-homepage <os> : Open homepage for the OS
--show [os] : Show one, or all, OS information --show [os] : Show OS information
--version : Show version --version : Show version
--help : Show this help message --help : Show this help message
-------------------------- For testing & development --------------------------- -------------------------- For testing & development ---------------------------