Skip to content

Commit

Permalink
🐞 FIX: Issue #5 & #8 bash syntax and location of plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
dabrown645 committed Feb 8, 2024
1 parent 49caf43 commit ca14e41
Showing 1 changed file with 20 additions and 14 deletions.
34 changes: 20 additions & 14 deletions quickget
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,18 @@ function main() {
fi

PARAMS=""
BASE_DIR="${BASH_SOURCE[0]%%/*}"
PLUGINS="${BASE_DIR}/quickget_plugins"
BASE_DIR="$(dirname "${BASEDIR_SOURCE}")"
if [[ "${BASE_DIR}" == '.' ]]; then
PLUGINS="${BASE_DIR}/quickget_plugins" # < used in development
else
PLUGINS="/usr/share/quickemu/quickget_plugins" # < used for production
fi
TMPDIR="${HOME}/quickget-tmp" # to be used for temp files if needed
mkdir -p "${TMPDIR}"
# will automaticly get deleted
# will automatically get deleted

# Set defaults for arguments
declare -A DISTRO_INFO # This get set in get_distro_info then made readonly
declare -A DISTRO_INFO # This get set in get_distro_info then made read only
TEST_ISO_URL=false
SHOW_ISO_URL=false
OPEN_DISTRO_HOME_PAGE=false
Expand Down Expand Up @@ -63,7 +67,7 @@ function main() {
esac
;;
--*|-*) # unsupported flags
error "Unsuppotred flag ${1}"
error "Unsupported flag ${1}"
shift
usage
;;
Expand Down Expand Up @@ -92,14 +96,19 @@ function main() {
printf "\n"
usage
elif ! valid_os "${OS}"; then
error "${OS} is not a valid os please resubmit with valid os"
error "${OS} is not a valid OS please resubmit with valid OS"
printf "Valid OS's:\n"
supported_oses
printf "\n"
usage
else # shellcheck disable=SC1090
source "${PLUGINS}/${OS}".plug # get OS specific version of functions

if ${OPEN_DISTRO_HOME_PAGE}; then
open_url "$(homepage)"
exit 0
fi

declare -r -A EDITIONS="($(editions))"

if [ -z "${RELEASE}" ]; then
Expand Down Expand Up @@ -135,7 +144,7 @@ function main() {
fi
else
if [ -n "${EDITION}" ]; then
error "Edition is not aloud you must specify only a vlaid release ${OS}"
error "Edition is not aloud you must specify only a valid release ${OS}"
release_editions
usage
else
Expand All @@ -160,10 +169,7 @@ function main() {
printf "%-5s: %s\n" "${key}" "${DISTRO_INFO["${key}"]}"
done | sort

if ${OPEN_DISTRO_HOME_PAGE}; then
open_url "$(homepage)"
exit 0
elif ${SHOW_ISO_URL}; then
if ${SHOW_ISO_URL}; then
show_iso_url
exit 0
elif ${TEST_ISO_URL}; then
Expand Down Expand Up @@ -253,13 +259,13 @@ function error() {
}

function edition_valid() {
# This function valiates that the supplied edition is one of the
# This function validates that the supplied edition is one of the
# valid releases
[[ "${EDITIONS["${RELEASE}"]}" == *"${EDITION}"* ]] && return 0 || return 1
}

function release_valid() {
# This function valiates that the supplied relese is one of the
# This function validates that the supplied release is one of the
# valid releases
for value in $(releases); do
[[ "${RELEASE}" == "${value}" ]] && return 0
Expand Down Expand Up @@ -303,7 +309,7 @@ function list_json {

function open_url() {
local url=${1}
xdg-open "${url}" || sensible-brownser "${url}" || x-www-browser "${url}" || gnome-open "${url}";
xdg-open "${url}" || sensible-browser "${url}" || x-www-browser "${url}" || gnome-open "${url}";
}

function release_editions(){
Expand Down

0 comments on commit ca14e41

Please sign in to comment.