Skip to content

Commit e426797

Browse files
committed
feat: enhanced update_script function to allow for dev branch updates
1 parent 6aad03b commit e426797

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

ani-cli

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,15 +105,15 @@ version_info() {
105105
}
106106

107107
update_script() {
108-
update="$(curl -s -A "$agent" "https://raw.githubusercontent.com/pystardust/ani-cli/master/ani-cli")" || die "Connection error"
108+
update="$(curl -s -A "$agent" "https://raw.githubusercontent.com/pystardust/ani-cli/$branch/ani-cli")" || die "Connection error"
109109
update="$(printf '%s\n' "$update" | diff -u "$0" -)"
110110
if [ -z "$update" ]; then
111-
printf "Script is up to date :)\n"
111+
printf "[branch:%s] Script is up to date :)\n" "$branch"
112112
else
113113
if printf '%s\n' "$update" | patch "$0" -; then
114-
printf "Script has been updated\n"
114+
printf "[branch:%s] Script has been updated\n" "$branch"
115115
else
116-
die "Can't update for some reason!"
116+
die "[branch:$branch] Can't update for some reason!"
117117
fi
118118
fi
119119
exit 0
@@ -508,6 +508,7 @@ hist_dir="${ANI_CLI_HIST_DIR:-${XDG_STATE_HOME:-$HOME/.local/state}/ani-cli}"
508508
histfile="$hist_dir/ani-hsts"
509509
[ ! -f "$histfile" ] && : >"$histfile"
510510
search="${ANI_CLI_DEFAULT_SOURCE:-scrape}"
511+
branch="${ANI_CLI_BRANCH:-master}"
511512

512513
while [ $# -gt 0 ]; do
513514
case "$1" in
@@ -575,7 +576,10 @@ while [ $# -gt 0 ]; do
575576
shift
576577
;;
577578
-N | --nextep-countdown) search=nextep ;;
578-
-U | --update) update_script ;;
579+
-U | --update)
580+
branch="${2:-$branch}"
581+
update_script
582+
;;
579583
*) query="$(printf "%s" "$query $1" | sed "s|^ ||;s| |+|g")" ;;
580584
esac
581585
shift

0 commit comments

Comments
 (0)