forked from bahamas10/ysap
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmake-legend
More file actions
executable file
·78 lines (65 loc) · 1.54 KB
/
Copy pathmake-legend
File metadata and controls
executable file
·78 lines (65 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/usr/bin/env bash
#
# Generate the Legend (help message) - intended to be passed to `tools/box`
#
# Author: Dave Eddy <dave@daveeddy.com>
# Date: April 05, 2025
# License: MIT
. ./theme || exit
UNDERLINE=$'\x1b[3m'
format-box() {
local title=$1
shift
if [[ -z $1 ]]; then
return
fi
local cmd_re='^(\$ [^ ]+)(.*)$'
{
echo '%'
local line name url
for line in "$@"; do
IFS='%' read -r name url <<< "$line"
if [[ $name =~ $cmd_re ]]; then
local cmd=${BASH_REMATCH[1]}
local rest=${BASH_REMATCH[2]}
echo -n "$COLOR3$cmd$RST$COLOR5$rest"
else
echo -n "$COLOR5$name$RST"
fi
echo -n '%'
echo -n "$COLOR1$UNDERLINE$url$RST"
echo
done
} | ./tools/box -s '%' -hp 1 -tc "$COLOR5" -T plain -t "$title"
}
full='false'
while getopts 'f' opt; do
case "$opt" in
f) full='true';;
*) exit 1;;
esac
done
legend=(
'$ curl ysap.sh%Get this page'
'$ curl ysap.sh/episodes%Get the list of episodes in the YSAP series'
'$ curl ysap.sh/json%Get the above in JSON format'
'$ curl ysap.sh/help%Get the full list of available endpoints'
)
resources=()
extras=()
if $full; then
legend+=(
'$ curl ysap.sh/ping%Get a 200 with the text pong'
'$ curl [-46] ysap.sh/ip%Get your current IP address as a string'
)
resources+=(
'$ curl style.ysap.sh%Bash Style Guide for writing safe scripts'
)
extras+=(
'$ curl xmas.ysap.sh | bash%Christmas tree animation'
'$ curl nightfall.ysap.sh | bash%Music Album TUI'
)
fi
format-box Legend "${legend[@]}"
format-box Resources "${resources[@]}"
format-box Extras "${extras[@]}"