Skip to content

Commit fd8df5f

Browse files
committed
feat(base): make cheat's topic argument optional and drop https
cht.sh serves the same content over plain http, and requesting it without a topic (cheat with no args) returns its general help page, so there's no reason to require an argument. Regenerate README's function-line links, shifted by the fix.
1 parent b53f42c commit fd8df5f

3 files changed

Lines changed: 66 additions & 67 deletions

File tree

‎README.adoc‎

Lines changed: 60 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -93,62 +93,62 @@ The public functions are, in alphabetical order:
9393
{url-base}#L105[`beuser`],
9494
{url-base}#L119[`bomb`],
9595
{url-base}#L125[`cheat`],
96-
{url-base}#L137[`chrono_get`],
97-
{url-base}#L182[`chrono_sta`],
98-
{url-base}#L199[`chrono_sto`],
99-
{url-base}#L220[`cmd_exists`],
100-
{url-base}#L257[`cmd_run`],
101-
{url-base}#L291[`cmd_runif`],
102-
{url-base}#L300[`cya`],
103-
{url-base}#L310[`die`],
104-
{url-base}#L318[`dng2jpg`],
105-
{url-base}#L327[`echo`],
106-
{url-base}#L347[`ellipsize`],
107-
{url-base}#L380[`file_exists`],
108-
{url-base}#L396[`gitfix`],
109-
{url-base}#L412[`gitlog`],
110-
{url-base}#L438[`grbt`],
111-
{url-base}#L456[`handle_pipefails`],
112-
{url-base}#L467[`heic2jpg`],
113-
{url-base}#L480[`inside`],
114-
{url-base}#L492[`isempty`],
115-
{url-base}#L521[`isfunc`],
116-
{url-base}#L538[`isnumber`],
117-
{url-base}#L550[`isreadable`],
118-
{url-base}#L563[`isroot`],
119-
{url-base}#L576[`issolid`],
120-
{url-base}#L614[`iswritable`],
121-
{url-base}#L631[`log`],
122-
{url-base}#L640[`loge`],
123-
{url-base}#L648[`logw`],
124-
{url-base}#L657[`map_del`],
125-
{url-base}#L681[`map_get`],
126-
{url-base}#L707[`map_put`],
127-
{url-base}#L728[`nmea2gpx`],
128-
{url-base}#L742[`pdf2jpg`],
129-
{url-base}#L747[`pdf2png`],
130-
{url-base}#L769[`prettytable`],
131-
{url-base}#L790[`prettyuptime`],
132-
{url-base}#L814[`realdir`],
133-
{url-base}#L828[`realpath`],
134-
{url-base}#L846[`retry`],
135-
{url-base}#L884[`rev`],
136-
{url-base}#L902[`semver`],
137-
{url-base}#L931[`should_continue`],
138-
{url-base}#L989[`timestamp`],
139-
{url-base}#L1009[`tolog`],
140-
{url-base}#L1015[`tologe`],
141-
{url-base}#L1022[`tolower`],
142-
{url-base}#L1040[`totsout`],
143-
{url-base}#L1046[`tsout`],
144-
{url-base}#L1055[`url_exists`],
145-
{url-base}#L1084[`user_exists`],
146-
{url-base}#L1103[`validate_cmd`],
147-
{url-base}#L1110[`validate_var`],
148-
{url-base}#L1128[`var_exists`],
149-
{url-base}#L1168[`ver_ge`],
150-
{url-base}#L1183[`vid2aud`],
151-
{url-base}#L1204[`ytda`].
96+
{url-base}#L136[`chrono_get`],
97+
{url-base}#L181[`chrono_sta`],
98+
{url-base}#L198[`chrono_sto`],
99+
{url-base}#L219[`cmd_exists`],
100+
{url-base}#L256[`cmd_run`],
101+
{url-base}#L290[`cmd_runif`],
102+
{url-base}#L299[`cya`],
103+
{url-base}#L309[`die`],
104+
{url-base}#L317[`dng2jpg`],
105+
{url-base}#L326[`echo`],
106+
{url-base}#L346[`ellipsize`],
107+
{url-base}#L379[`file_exists`],
108+
{url-base}#L395[`gitfix`],
109+
{url-base}#L411[`gitlog`],
110+
{url-base}#L437[`grbt`],
111+
{url-base}#L455[`handle_pipefails`],
112+
{url-base}#L466[`heic2jpg`],
113+
{url-base}#L479[`inside`],
114+
{url-base}#L491[`isempty`],
115+
{url-base}#L520[`isfunc`],
116+
{url-base}#L537[`isnumber`],
117+
{url-base}#L549[`isreadable`],
118+
{url-base}#L562[`isroot`],
119+
{url-base}#L575[`issolid`],
120+
{url-base}#L613[`iswritable`],
121+
{url-base}#L630[`log`],
122+
{url-base}#L639[`loge`],
123+
{url-base}#L647[`logw`],
124+
{url-base}#L656[`map_del`],
125+
{url-base}#L680[`map_get`],
126+
{url-base}#L706[`map_put`],
127+
{url-base}#L727[`nmea2gpx`],
128+
{url-base}#L741[`pdf2jpg`],
129+
{url-base}#L746[`pdf2png`],
130+
{url-base}#L768[`prettytable`],
131+
{url-base}#L789[`prettyuptime`],
132+
{url-base}#L813[`realdir`],
133+
{url-base}#L827[`realpath`],
134+
{url-base}#L845[`retry`],
135+
{url-base}#L883[`rev`],
136+
{url-base}#L901[`semver`],
137+
{url-base}#L930[`should_continue`],
138+
{url-base}#L988[`timestamp`],
139+
{url-base}#L1008[`tolog`],
140+
{url-base}#L1014[`tologe`],
141+
{url-base}#L1021[`tolower`],
142+
{url-base}#L1039[`totsout`],
143+
{url-base}#L1045[`tsout`],
144+
{url-base}#L1054[`url_exists`],
145+
{url-base}#L1083[`user_exists`],
146+
{url-base}#L1102[`validate_cmd`],
147+
{url-base}#L1109[`validate_var`],
148+
{url-base}#L1127[`var_exists`],
149+
{url-base}#L1167[`ver_ge`],
150+
{url-base}#L1182[`vid2aud`],
151+
{url-base}#L1203[`ytda`].
152152

153153
Global variables carry the `BASE_` prefix.
154154
Clients may use them and should place temporary files under `$BASE_WIP`.
@@ -207,9 +207,9 @@ log I\'m using the shellbase.
207207
----
208208

209209
The framework provides three loggers:
210-
{url-base}#L631[`log`] for information,
211-
{url-base}#L640[`loge`] for errors, and
212-
{url-base}#L648[`logw`] for warnings.
210+
{url-base}#L630[`log`] for information,
211+
{url-base}#L639[`loge`] for errors, and
212+
{url-base}#L647[`logw`] for warnings.
213213
Each logger prints to standard error.
214214
In non-interactive mode, each also appends the message to the log file under
215215
a single lowercase level tag: `i` for information, `e` for errors, and `w`
@@ -233,7 +233,7 @@ eval "$(
233233
log I\'m using the shellbase.
234234
----
235235

236-
{url-base}#L769[`prettytable`] example:
236+
{url-base}#L768[`prettytable`] example:
237237

238238
[,sh]
239239
----

‎app/test-cheat-arg-no‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
# SPDX-FileCopyrightText: 2026 David Rabkin
44
# SPDX-License-Identifier: 0BSD
55
#
6-
# Verifies that cheat fails when called without a topic.
6+
# Verifies that cheat fails when called with more than one topic.
77
#
88
# File not following:
99
# shellcheck disable=SC1090,SC1091
1010
. "$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd -P)"/../lib/base.sh
11-
cheat
11+
cheat too many
1212
log Cheat sheet fetched.

‎lib/base.sh‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,14 +121,13 @@ bomb() {
121121
base_bomb
122122
}
123123

124-
# The only cheat sheet you need. The only parameter is the topic.
124+
# The only cheat sheet you need. The parameter is the topic.
125125
cheat() {
126-
[ $# -eq 1 ] || {
127-
loge Expected a single argument, got "$#".
126+
[ $# -le 1 ] || {
127+
loge Expected at most a single argument, got "$#".
128128
return $BASE_RC_ARG_NO
129129
}
130-
cmd_exists curl || return
131-
curl https://cht.sh/"$1"
130+
cmd_exists curl && curl cht.sh/"${1-}"
132131
}
133132

134133
# Calculates a duration from the start. There are 86400 seconds in a day,

0 commit comments

Comments
 (0)