Skip to content

Commit

Permalink
[eos-bash-shared] small code reorganization in eos-pkg-changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
manuel-192 committed Jan 6, 2025
1 parent 9635a8c commit a088074
Showing 1 changed file with 27 additions and 17 deletions.
44 changes: 27 additions & 17 deletions eos-pkg-changelog
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Usage: $progname [options] package-name(s)
Options: --help, -h This help.
--github Uses github for showing the changelog.
--gitlab Uses gitlab for showing the changelog.
--parameters Show supported package names and options.
--parameters Show supported package names and options. Implies option -d.
--clfile=X, -c=X Replace PKG_CHANGELOGS array with a new one in (bash) file 'X'.
--detect-clfile, -d Detects possible changelog file at '$clfile_def'.
--url, -u Simply print the changelog URL instead of opening it in a browser.
Expand All @@ -22,6 +22,28 @@ EOF
[ "$1" ] && exit $1
}

DumpPkgnames() {
declare -p PKG_CHANGELOGS | sed 's|\[|\n\[|g' | grep "^\[" | sed -E 's|^\[([^]]*).*|\1|'
}
DumpOptions() {
local sopts2=${sopts//:/}
local lopts2=${lopts//:/}
printf "%s\n" ${sopts2//?/-& }--${lopts2//,/ --}
}
DetectClFile() {
local mode="$1"
clfile="$clfile_def"
if [ -e "$clfile" ] ; then
[ "$mode" = verbose ] && INFO "reading $clfile..."
source "$clfile" || DIE "reading $clfile failed"
else
case "$REPONAME" in
endeavouros | "") ;; # $clfile not found | using predefined EndeavourOS changelog definitions
*) DIE "$clfile not found" ;;
esac
fi
}

Parameters() {
local sopts="c:dhu"
local lopts="help,github,gitlab,parameters,clfile:,detect-clfile,quiet,url"
Expand All @@ -38,24 +60,12 @@ Parameters() {
source "$clfile" || DIE "reading $clfile failed" # get new PKG_CHANGELOGS and REPONAME
;;
--detect-clfile | -d)
clfile="$clfile_def"
if [ -e "$clfile" ] ; then
INFO "reading $clfile..."
source "$clfile" || DIE "reading $clfile failed"
else
case "$REPONAME" in
endeavouros | "") ;; # $clfile not found | using predefined EndeavourOS changelog definitions
*) DIE "$clfile not found" ;;
esac
fi
DetectClFile verbose
;;
--parameters)
# Dump names of supported packages and options.
declare -p PKG_CHANGELOGS | sed 's|\[|\n\[|g' | grep "^\[" | sed -E 's|^\[([^]]*).*|\1|'

local sopts2=${sopts//:/}
local lopts2=${lopts//:/}
printf "%s\n" ${sopts2//?/-& }--${lopts2//,/ --}
DetectClFile
DumpPkgnames
DumpOptions
exit 0
;;
--github | --gitlab) preferred_site=${1:2} ;;
Expand Down

0 comments on commit a088074

Please sign in to comment.