@@ -14,20 +14,25 @@ TOWEL_GITHUB_REPO="${TOWEL_GITHUB_REPO:-codam-coding-college/towel}"
1414
1515function print_usage() {
1616 echo 1>&2 " Usage:
17- towel update --check [--quiet]
18- towel update --apply [-y|--yes]
17+ towel update --check [--quiet]
18+ towel update --apply [-y|--yes]
19+ towel update --no-auto-check
20+ towel update --auto-check
1921 towel update [-h|--help]
2022
2123Flags:
22- --check Query GitHub for the latest release and compare to the installed version.
23- Exits 0 if up to date, 10 if an update is available, 1 on error.
24- --apply Download, verify, and install the latest release.
25- -y, --yes Skip the confirmation prompt (--apply only).
26- --quiet Suppress stdout output (--check only; stderr and exit code preserved).
27- -h, --help Print this help text.
24+ --check Query GitHub for the latest release and compare to the installed version.
25+ Exits 0 if up to date, 10 if an update is available, 1 on error.
26+ --apply Download, verify, and install the latest release.
27+ -y, --yes Skip the confirmation prompt (--apply only).
28+ --quiet Suppress stdout output (--check only; stderr and exit code preserved).
29+ --no-auto-check Disable the automatic daily update check and notifications.
30+ --auto-check Re-enable the automatic daily update check.
31+ -h, --help Print this help text.
2832
2933Environment:
30- TOWEL_GITHUB_REPO Override the GitHub owner/repo (default: codam-coding-college/towel)."
34+ TOWEL_GITHUB_REPO Override the GitHub owner/repo (default: codam-coding-college/towel)
35+ TOWEL_NO_UPDATE_CHECK Set to 1 to disable automatic update checks."
3136}
3237
3338function _towel_update_compare() {
@@ -67,6 +72,8 @@ for arg in "$@"; do
6772 case " $arg " in
6873 --check) mode=" check" ;;
6974 --apply) mode=" apply" ;;
75+ --no-auto-check) mode=" no-auto-check" ;;
76+ --auto-check) mode=" auto-check" ;;
7077 -y | --yes) assume_yes=" true" ;;
7178 --quiet) quiet=" true" ;;
7279 -h | --help)
@@ -82,11 +89,24 @@ for arg in "$@"; do
8289done
8390
8491if [ -z " $mode " ]; then
85- echo 1>&2 " towel update: a mode flag is required (--check or --apply )"
92+ echo 1>&2 " towel update: a mode flag is required (--check, --apply, --no-auto-check, or --auto-check )"
8693 print_usage
8794 exit 64
8895fi
8996
97+ if [ " $mode " = " no-auto-check" ]; then
98+ touch " $TOWEL_DATA /no-update-check"
99+ echo " Automatic update checks disabled."
100+ echo " Re-enable with: towel update --auto-check"
101+ exit 0
102+ fi
103+
104+ if [ " $mode " = " auto-check" ]; then
105+ rm -f " $TOWEL_DATA /no-update-check" " $TOWEL_DATA /update_check" " $TOWEL_DATA /update_notified"
106+ echo " Automatic update checks enabled."
107+ exit 0
108+ fi
109+
90110latest_version=" $( _towel_fetch_latest_version) " || {
91111 echo 1>&2 " towel update --${mode} failed: could not reach GitHub API (check network connectivity)"
92112 exit 1
0 commit comments