homebridge-tasmota 0.1.6 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/DEVICES.md +39 -38
- package/gh-md-toc +201 -46
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. This project uses [Semantic Versioning](https://semver.org/).
|
|
4
4
|
|
|
5
|
+
## 0.1.7 (2023-05-15)
|
|
6
|
+
|
|
7
|
+
## [Version 0.1.3](https://github.com/northernman54/homebridge-tasmota/compare/v0.1.4...v0.1.7)
|
|
8
|
+
|
|
9
|
+
#### Changes
|
|
10
|
+
|
|
11
|
+
- Fixed Outlet in Use
|
|
12
|
+
- Fixes for #45 #44 #35
|
|
13
|
+
|
|
5
14
|
## 0.1.4 (2021-06-07)
|
|
6
15
|
|
|
7
16
|
## [Version 0.1.3](https://github.com/northernman54/homebridge-tasmota/compare/v0.1.3...v0.1.4)
|
package/DEVICES.md
CHANGED
|
@@ -1,44 +1,45 @@
|
|
|
1
1
|
<H1>Sample Device Configurations ( My personal collection )</H1>
|
|
2
2
|
|
|
3
3
|
<!--ts-->
|
|
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
|
-
<!--
|
|
4
|
+
* [Sample Device Configurations ( My personal collection )](#sample-device-configurations--my-personal-collection-)
|
|
5
|
+
* [My standard config after setting name and device configuration ](#my-standard-config-after-setting-name-and-device-configuration-)
|
|
6
|
+
* [Tasmota Configuration](#tasmota-configuration)
|
|
7
|
+
* [Sonoff IFAN03](#sonoff-ifan03)
|
|
8
|
+
* [Tasmota Configuration](#tasmota-configuration-1)
|
|
9
|
+
* [configuration override of discovery object to create a FAN ( post version 0.1.0 )](#configuration-override-of-discovery-object-to-create-a-fan--post-version-010-)
|
|
10
|
+
* [configuration override of discovery object to create a FAN ( pre version 0.1.0 )](#configuration-override-of-discovery-object-to-create-a-fan--pre-version-010-)
|
|
11
|
+
* [Slave a FEIT Wifi Dimmer Wall Switch to an iFan as a light switch](#slave-a-feit-wifi-dimmer-wall-switch-to-an-ifan-as-a-light-switch)
|
|
12
|
+
* [BME280 Temperature Sensor - <a href="docs/MCUIOT.md">MCUIOT</a>](#bme280-temperature-sensor---mcuiot)
|
|
13
|
+
* [DHT11 Temperature Sensor - <a href="docs/MCUIOT.md">MCUIOT</a>](#dht11-temperature-sensor---mcuiot)
|
|
14
|
+
* [Water Leak Sensor with On/Off control](#water-leak-sensor-with-onoff-control)
|
|
15
|
+
* [LEAK Tasmota configuration - <a href="docs/MCUIOT.md#dht-yl">DHT11</a>](#leak-tasmota-configuration---dht11)
|
|
16
|
+
* [Leak Tasmota configuration - <a href="docs/MCUIOT.md#dht-yl">BME280</a>](#leak-tasmota-configuration---bme280)
|
|
17
|
+
* [Motion + BME280 Temperature Sensor](#motion--bme280-temperature-sensor)
|
|
18
|
+
* [PIR Motion + BME280 Temperature Sensor + BH1750 Lux Illuminance Sensor](#pir-motion--bme280-temperature-sensor--bh1750-lux-illuminance-sensor)
|
|
19
|
+
* [ZMAi-90 Current Sensor Switch](#zmai-90-current-sensor-switch)
|
|
20
|
+
* [MCULED Device with RGB+W Strip](#mculed-device-with-rgbw-strip)
|
|
21
|
+
* [MCULED Device with RGB+W Strip - Version 2 ( Basement )](#mculed-device-with-rgbw-strip---version-2--basement-)
|
|
22
|
+
* [MCULED Device with RGB+W Strip - Version 2 ( Cottage Sink )](#mculed-device-with-rgbw-strip---version-2--cottage-sink-)
|
|
23
|
+
* [Tuya Dimmer Module as a FAN](#tuya-dimmer-module-as-a-fan)
|
|
24
|
+
* [Trailer Relay Board](#trailer-relay-board)
|
|
25
|
+
* [Gowfeel EN71 Water Valve](#gowfeel-en71-water-valve)
|
|
26
|
+
* [Homebrew Garage Door Opener](#homebrew-garage-door-opener)
|
|
27
|
+
* [CE SMART Wifi Dimmer](#ce-smart-wifi-dimmer)
|
|
28
|
+
* [FEIT Wifi Dimmer](#feit-wifi-dimmer)
|
|
29
|
+
* [Turn off after 30 minutes](#turn-off-after-30-minutes)
|
|
30
|
+
* [Hampton Bay Fan/Light RF Remote Control ( 303.9 Mhz )](#hampton-bay-fanlight-rf-remote-control--3039-mhz-)
|
|
31
|
+
* [Valor Fireplace Remote ( 315 Mhz )](#valor-fireplace-remote--315-mhz-)
|
|
32
|
+
* [Treatlife DS03 Fan Controller and Light Dimmer](#treatlife-ds03-fan-controller-and-light-dimmer)
|
|
33
|
+
* [OpenMQTTGateway devices](#openmqttgateway-devices)
|
|
34
|
+
* [Hampton Bay Light](#hampton-bay-light)
|
|
35
|
+
* [Hampton Bay FAN](#hampton-bay-fan)
|
|
36
|
+
* [openMQTTGateway / PiLight temperature sensor](#openmqttgateway--pilight-temperature-sensor)
|
|
37
|
+
* [Internet Connection WatchDog](#internet-connection-watchdog)
|
|
38
|
+
* [Version 1 ( Uses node-red to monitor google.com and turn off the plug )](#version-1--uses-node-red-to-monitor-googlecom-and-turn-off-the-plug-)
|
|
39
|
+
* [Version 2](#version-2)
|
|
40
|
+
|
|
41
|
+
<!-- Created by https://github.com/ekalinin/github-markdown-toc -->
|
|
42
|
+
<!-- Added by: sgracey, at: Mon 15 May 2023 20:05:38 EDT -->
|
|
42
43
|
|
|
43
44
|
<!--te-->
|
|
44
45
|
|
package/gh-md-toc
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
# substr($0, length($0), 1)
|
|
15
15
|
#
|
|
16
16
|
# 3.2 Get level from 3.1 and insert corresponding number of spaces before '*':
|
|
17
|
-
# sprintf("%*s",
|
|
17
|
+
# sprintf("%*s", (level-1)*'"$nb_spaces"', "")
|
|
18
18
|
#
|
|
19
19
|
# 4. Find head's text and insert it inside "* [ ... ]":
|
|
20
20
|
# substr($0, match($0, /a>.*<\/h/)+2, RLENGTH-5)
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
# substr($0, match($0, "href=\"[^\"]+?\" ")+6, RLENGTH-8)
|
|
24
24
|
#
|
|
25
25
|
|
|
26
|
-
gh_toc_version="0.
|
|
26
|
+
gh_toc_version="0.8.0"
|
|
27
27
|
|
|
28
28
|
gh_user_agent="gh-md-toc v$gh_toc_version"
|
|
29
29
|
|
|
@@ -47,18 +47,44 @@ gh_toc_load() {
|
|
|
47
47
|
#
|
|
48
48
|
# Converts local md file into html by GitHub
|
|
49
49
|
#
|
|
50
|
-
#
|
|
50
|
+
# -> curl -X POST --data '{"text": "Hello world github/linguist#1 **cool**, and #1!"}' https://api.github.com/markdown
|
|
51
51
|
# <p>Hello world github/linguist#1 <strong>cool</strong>, and #1!</p>'"
|
|
52
52
|
gh_toc_md2html() {
|
|
53
53
|
local gh_file_md=$1
|
|
54
|
+
local skip_header=$2
|
|
55
|
+
|
|
54
56
|
URL=https://api.github.com/markdown/raw
|
|
55
|
-
|
|
56
|
-
if [ -
|
|
57
|
-
|
|
57
|
+
|
|
58
|
+
if [ ! -z "$GH_TOC_TOKEN" ]; then
|
|
59
|
+
TOKEN=$GH_TOC_TOKEN
|
|
60
|
+
else
|
|
61
|
+
TOKEN_FILE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/token.txt"
|
|
62
|
+
if [ -f "$TOKEN_FILE" ]; then
|
|
63
|
+
TOKEN="$(cat $TOKEN_FILE)"
|
|
64
|
+
fi
|
|
65
|
+
fi
|
|
66
|
+
if [ ! -z "${TOKEN}" ]; then
|
|
67
|
+
AUTHORIZATION="Authorization: token ${TOKEN}"
|
|
58
68
|
fi
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
69
|
+
|
|
70
|
+
local gh_tmp_file_md=$gh_file_md
|
|
71
|
+
if [ "$skip_header" = "yes" ]; then
|
|
72
|
+
if grep -Fxq "<!--te-->" "$gh_src"; then
|
|
73
|
+
# cut everything before the toc
|
|
74
|
+
gh_tmp_file_md=$gh_file_md~~
|
|
75
|
+
sed '1,/<!--te-->/d' $gh_file_md > $gh_tmp_file_md
|
|
76
|
+
fi
|
|
77
|
+
fi
|
|
78
|
+
|
|
79
|
+
# echo $URL 1>&2
|
|
80
|
+
OUTPUT=$(curl -s \
|
|
81
|
+
--user-agent "$gh_user_agent" \
|
|
82
|
+
--data-binary @"$gh_tmp_file_md" \
|
|
83
|
+
-H "Content-Type:text/plain" \
|
|
84
|
+
-H "$AUTHORIZATION" \
|
|
85
|
+
"$URL")
|
|
86
|
+
|
|
87
|
+
rm -f $gh_file_md~~
|
|
62
88
|
|
|
63
89
|
if [ "$?" != "0" ]; then
|
|
64
90
|
echo "XXNetworkErrorXX"
|
|
@@ -91,6 +117,10 @@ gh_toc(){
|
|
|
91
117
|
local gh_src_copy=$1
|
|
92
118
|
local gh_ttl_docs=$2
|
|
93
119
|
local need_replace=$3
|
|
120
|
+
local no_backup=$4
|
|
121
|
+
local no_footer=$5
|
|
122
|
+
local indent=$6
|
|
123
|
+
local skip_header=$7
|
|
94
124
|
|
|
95
125
|
if [ "$gh_src" = "" ]; then
|
|
96
126
|
echo "Please, enter URL or local path for a README.md"
|
|
@@ -109,7 +139,7 @@ gh_toc(){
|
|
|
109
139
|
fi
|
|
110
140
|
|
|
111
141
|
if [ "$(gh_is_url "$gh_src")" == "yes" ]; then
|
|
112
|
-
gh_toc_load "$gh_src" | gh_toc_grab "$gh_src_copy"
|
|
142
|
+
gh_toc_load "$gh_src" | gh_toc_grab "$gh_src_copy" "$indent"
|
|
113
143
|
if [ "${PIPESTATUS[0]}" != "0" ]; then
|
|
114
144
|
echo "Could not load remote document."
|
|
115
145
|
echo "Please check your url or network connectivity"
|
|
@@ -122,7 +152,7 @@ gh_toc(){
|
|
|
122
152
|
echo
|
|
123
153
|
fi
|
|
124
154
|
else
|
|
125
|
-
local rawhtml=$(gh_toc_md2html "$gh_src")
|
|
155
|
+
local rawhtml=$(gh_toc_md2html "$gh_src" "$skip_header")
|
|
126
156
|
if [ "$rawhtml" == "XXNetworkErrorXX" ]; then
|
|
127
157
|
echo "Parsing local markdown file requires access to github API"
|
|
128
158
|
echo "Please make sure curl is installed and check your network connectivity"
|
|
@@ -131,35 +161,50 @@ gh_toc(){
|
|
|
131
161
|
if [ "$rawhtml" == "XXRateLimitXX" ]; then
|
|
132
162
|
echo "Parsing local markdown file requires access to github API"
|
|
133
163
|
echo "Error: You exceeded the hourly limit. See: https://developer.github.com/v3/#rate-limiting"
|
|
134
|
-
|
|
135
|
-
echo "or place
|
|
164
|
+
TOKEN_FILE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/token.txt"
|
|
165
|
+
echo "or place GitHub auth token here: ${TOKEN_FILE}"
|
|
136
166
|
exit 1
|
|
137
167
|
fi
|
|
138
|
-
local toc=`echo "$rawhtml" | gh_toc_grab "$gh_src_copy"`
|
|
168
|
+
local toc=`echo "$rawhtml" | gh_toc_grab "$gh_src_copy" "$indent"`
|
|
139
169
|
echo "$toc"
|
|
140
170
|
if [ "$need_replace" = "yes" ]; then
|
|
171
|
+
if grep -Fxq "<!--ts-->" "$gh_src" && grep -Fxq "<!--te-->" "$gh_src"; then
|
|
172
|
+
echo "Found markers"
|
|
173
|
+
else
|
|
174
|
+
echo "You don't have <!--ts--> or <!--te--> in your file...exiting"
|
|
175
|
+
exit 1
|
|
176
|
+
fi
|
|
141
177
|
local ts="<\!--ts-->"
|
|
142
178
|
local te="<\!--te-->"
|
|
143
179
|
local dt=`date +'%F_%H%M%S'`
|
|
144
180
|
local ext=".orig.${dt}"
|
|
145
181
|
local toc_path="${gh_src}.toc.${dt}"
|
|
146
|
-
local
|
|
182
|
+
local toc_createdby="<!-- Created by https://github.com/ekalinin/github-markdown-toc -->"
|
|
183
|
+
local toc_footer="<!-- Added by: `whoami`, at: `date` -->"
|
|
147
184
|
# http://fahdshariff.blogspot.ru/2012/12/sed-mutli-line-replacement-between-two.html
|
|
148
185
|
# clear old TOC
|
|
149
186
|
sed -i${ext} "/${ts}/,/${te}/{//!d;}" "$gh_src"
|
|
150
187
|
# create toc file
|
|
151
188
|
echo "${toc}" > "${toc_path}"
|
|
152
|
-
|
|
189
|
+
if [ "${no_footer}" != "yes" ]; then
|
|
190
|
+
echo -e "\n${toc_createdby}\n${toc_footer}\n" >> "$toc_path"
|
|
191
|
+
fi
|
|
192
|
+
|
|
153
193
|
# insert toc file
|
|
154
|
-
if
|
|
194
|
+
if ! sed --version > /dev/null 2>&1; then
|
|
155
195
|
sed -i "" "/${ts}/r ${toc_path}" "$gh_src"
|
|
156
196
|
else
|
|
157
197
|
sed -i "/${ts}/r ${toc_path}" "$gh_src"
|
|
158
198
|
fi
|
|
159
199
|
echo
|
|
200
|
+
if [ "${no_backup}" = "yes" ]; then
|
|
201
|
+
rm "$toc_path" "$gh_src$ext"
|
|
202
|
+
fi
|
|
160
203
|
echo "!! TOC was added into: '$gh_src'"
|
|
161
|
-
|
|
162
|
-
|
|
204
|
+
if [ -z "${no_backup}" ]; then
|
|
205
|
+
echo "!! Origin version of the file: '${gh_src}${ext}'"
|
|
206
|
+
echo "!! TOC added into a separate file: '${toc_path}'"
|
|
207
|
+
fi
|
|
163
208
|
echo
|
|
164
209
|
fi
|
|
165
210
|
fi
|
|
@@ -168,28 +213,77 @@ gh_toc(){
|
|
|
168
213
|
#
|
|
169
214
|
# Grabber of the TOC from rendered html
|
|
170
215
|
#
|
|
171
|
-
# $1
|
|
172
|
-
#
|
|
216
|
+
# $1 - a source url of document.
|
|
217
|
+
# It's need if TOC is generated for multiple documents.
|
|
218
|
+
# $2 - number of spaces used to indent.
|
|
173
219
|
#
|
|
174
220
|
gh_toc_grab() {
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
221
|
+
common_awk_script='
|
|
222
|
+
modified_href = ""
|
|
223
|
+
split(href, chars, "")
|
|
224
|
+
for (i=1;i <= length(href); i++) {
|
|
225
|
+
c = chars[i]
|
|
226
|
+
res = ""
|
|
227
|
+
if (c == "+") {
|
|
228
|
+
res = " "
|
|
229
|
+
} else {
|
|
230
|
+
if (c == "%") {
|
|
231
|
+
res = "\\x"
|
|
232
|
+
} else {
|
|
233
|
+
res = c ""
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
modified_href = modified_href res
|
|
237
|
+
}
|
|
238
|
+
print sprintf("%*s", (level-1)*'"$2"', "") "* [" text "](" gh_url modified_href ")"
|
|
239
|
+
'
|
|
240
|
+
if [ `uname -s` == "OS/390" ]; then
|
|
241
|
+
grepcmd="pcregrep -o"
|
|
242
|
+
echoargs=""
|
|
243
|
+
awkscript='{
|
|
244
|
+
level = substr($0, length($0), 1)
|
|
245
|
+
text = substr($0, match($0, /a>.*<\/h/)+2, RLENGTH-5)
|
|
246
|
+
href = substr($0, match($0, "href=\"([^\"]+)?\"")+6, RLENGTH-7)
|
|
247
|
+
'"$common_awk_script"'
|
|
248
|
+
}'
|
|
249
|
+
else
|
|
250
|
+
grepcmd="grep -Eo"
|
|
251
|
+
echoargs="-e"
|
|
252
|
+
awkscript='{
|
|
253
|
+
level = substr($0, length($0), 1)
|
|
254
|
+
text = substr($0, match($0, /a>.*<\/h/)+2, RLENGTH-5)
|
|
255
|
+
href = substr($0, match($0, "href=\"[^\"]+?\"")+6, RLENGTH-7)
|
|
256
|
+
'"$common_awk_script"'
|
|
257
|
+
}'
|
|
258
|
+
fi
|
|
259
|
+
href_regex='href=\"[^\"]+?\"'
|
|
260
|
+
|
|
261
|
+
# if closed <h[1-6]> is on the new line, then move it on the prev line
|
|
262
|
+
# for example:
|
|
263
|
+
# was: The command <code>foo1</code>
|
|
264
|
+
# </h1>
|
|
265
|
+
# became: The command <code>foo1</code></h1>
|
|
180
266
|
sed -e ':a' -e 'N' -e '$!ba' -e 's/\n<\/h/<\/h/g' |
|
|
267
|
+
|
|
181
268
|
# find strings that corresponds to template
|
|
182
|
-
|
|
269
|
+
$grepcmd '<a.*id="user-content-[^"]*".*</h[1-6]' |
|
|
270
|
+
|
|
183
271
|
# remove code tags
|
|
184
|
-
sed 's/<code>//' | sed 's/<\/code>//' |
|
|
272
|
+
sed 's/<code>//g' | sed 's/<\/code>//g' |
|
|
273
|
+
|
|
274
|
+
# remove g-emoji
|
|
275
|
+
sed 's/<g-emoji[^>]*[^<]*<\/g-emoji> //g' |
|
|
276
|
+
|
|
185
277
|
# now all rows are like:
|
|
186
278
|
# <a id="user-content-..." href="..."><span ...></span></a> ... </h1
|
|
187
279
|
# format result line
|
|
188
|
-
# * $0
|
|
189
|
-
|
|
190
|
-
|
|
280
|
+
# * $0 - whole string
|
|
281
|
+
# * last element of each row: "</hN" where N in (1,2,3,...)
|
|
282
|
+
echo $echoargs "$(awk -v "gh_url=$1" "$awkscript")"
|
|
191
283
|
}
|
|
192
284
|
|
|
285
|
+
# perl -lpE 's/(\[[^\]]*\]\()(.*?)(\))/my ($pre, $in, $post)=($1, $2, $3) ; $in =~ s{\+}{ }g; $in =~ s{%}{\\x}g; $pre.$in.$post/ems')"
|
|
286
|
+
|
|
193
287
|
#
|
|
194
288
|
# Returns filename only from full path or url
|
|
195
289
|
#
|
|
@@ -197,29 +291,67 @@ gh_toc_get_filename() {
|
|
|
197
291
|
echo "${1##*/}"
|
|
198
292
|
}
|
|
199
293
|
|
|
294
|
+
show_version() {
|
|
295
|
+
echo "$gh_toc_version"
|
|
296
|
+
echo
|
|
297
|
+
echo "os: `uname -s`"
|
|
298
|
+
echo "arch: `uname -m`"
|
|
299
|
+
echo "kernel: `uname -r`"
|
|
300
|
+
echo "shell: `$SHELL --version`"
|
|
301
|
+
echo
|
|
302
|
+
for tool in curl wget grep awk sed; do
|
|
303
|
+
printf "%-5s: " $tool
|
|
304
|
+
if `type $tool &>/dev/null`; then
|
|
305
|
+
echo `$tool --version | head -n 1`
|
|
306
|
+
else
|
|
307
|
+
echo "not installed"
|
|
308
|
+
fi
|
|
309
|
+
done
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
show_help() {
|
|
313
|
+
local app_name=$(basename "$0")
|
|
314
|
+
echo "GitHub TOC generator ($app_name): $gh_toc_version"
|
|
315
|
+
echo ""
|
|
316
|
+
echo "Usage:"
|
|
317
|
+
echo " $app_name [options] src [src] Create TOC for a README file (url or local path)"
|
|
318
|
+
echo " $app_name - Create TOC for markdown from STDIN"
|
|
319
|
+
echo " $app_name --help Show help"
|
|
320
|
+
echo " $app_name --version Show version"
|
|
321
|
+
echo ""
|
|
322
|
+
echo "Options:"
|
|
323
|
+
echo " --indent <NUM> Set indent size. Default: 3."
|
|
324
|
+
echo " --insert Insert new TOC into original file. For local files only. Default: false."
|
|
325
|
+
echo " See https://github.com/ekalinin/github-markdown-toc/issues/41 for details."
|
|
326
|
+
echo " --no-backup Remove backup file. Set --insert as well. Default: false."
|
|
327
|
+
echo " --hide-footer Do not write date & author of the last TOC update. Set --insert as well. Default: false."
|
|
328
|
+
echo " --skip-header Hide entry of the topmost headlines. Default: false."
|
|
329
|
+
echo " See https://github.com/ekalinin/github-markdown-toc/issues/125 for details."
|
|
330
|
+
echo ""
|
|
331
|
+
}
|
|
332
|
+
|
|
200
333
|
#
|
|
201
|
-
# Options
|
|
334
|
+
# Options handlers
|
|
202
335
|
#
|
|
203
336
|
gh_toc_app() {
|
|
204
|
-
local app_name=$(basename $0)
|
|
205
337
|
local need_replace="no"
|
|
338
|
+
local indent=3
|
|
206
339
|
|
|
207
340
|
if [ "$1" = '--help' ] || [ $# -eq 0 ] ; then
|
|
208
|
-
|
|
209
|
-
echo ""
|
|
210
|
-
echo "Usage:"
|
|
211
|
-
echo " $app_name [--insert] src [src] Create TOC for a README file (url or local path)"
|
|
212
|
-
echo " $app_name - Create TOC for markdown from STDIN"
|
|
213
|
-
echo " $app_name --help Show help"
|
|
214
|
-
echo " $app_name --version Show version"
|
|
341
|
+
show_help
|
|
215
342
|
return
|
|
216
343
|
fi
|
|
217
344
|
|
|
218
345
|
if [ "$1" = '--version' ]; then
|
|
219
|
-
|
|
346
|
+
show_version
|
|
220
347
|
return
|
|
221
348
|
fi
|
|
222
349
|
|
|
350
|
+
if [ "$1" = '--indent' ]; then
|
|
351
|
+
indent="$2"
|
|
352
|
+
shift 2
|
|
353
|
+
fi
|
|
354
|
+
|
|
223
355
|
if [ "$1" = "-" ]; then
|
|
224
356
|
if [ -z "$TMPDIR" ]; then
|
|
225
357
|
TMPDIR="/tmp"
|
|
@@ -227,11 +359,16 @@ gh_toc_app() {
|
|
|
227
359
|
mkdir -p "$TMPDIR"
|
|
228
360
|
fi
|
|
229
361
|
local gh_tmp_md
|
|
230
|
-
|
|
362
|
+
if [ `uname -s` == "OS/390" ]; then
|
|
363
|
+
local timestamp=$(date +%m%d%Y%H%M%S)
|
|
364
|
+
gh_tmp_md="$TMPDIR/tmp.$timestamp"
|
|
365
|
+
else
|
|
366
|
+
gh_tmp_md=$(mktemp $TMPDIR/tmp.XXXXXX)
|
|
367
|
+
fi
|
|
231
368
|
while read input; do
|
|
232
369
|
echo "$input" >> "$gh_tmp_md"
|
|
233
370
|
done
|
|
234
|
-
gh_toc_md2html "$gh_tmp_md" | gh_toc_grab ""
|
|
371
|
+
gh_toc_md2html "$gh_tmp_md" | gh_toc_grab "" "$indent"
|
|
235
372
|
return
|
|
236
373
|
fi
|
|
237
374
|
|
|
@@ -240,17 +377,35 @@ gh_toc_app() {
|
|
|
240
377
|
shift
|
|
241
378
|
fi
|
|
242
379
|
|
|
380
|
+
if [ "$1" = '--no-backup' ]; then
|
|
381
|
+
need_replace="yes"
|
|
382
|
+
no_backup="yes"
|
|
383
|
+
shift
|
|
384
|
+
fi
|
|
385
|
+
|
|
386
|
+
if [ "$1" = '--hide-footer' ]; then
|
|
387
|
+
need_replace="yes"
|
|
388
|
+
no_footer="yes"
|
|
389
|
+
shift
|
|
390
|
+
fi
|
|
391
|
+
|
|
392
|
+
if [ "$1" = '--skip-header' ]; then
|
|
393
|
+
skip_header="yes"
|
|
394
|
+
shift
|
|
395
|
+
fi
|
|
396
|
+
|
|
397
|
+
|
|
243
398
|
for md in "$@"
|
|
244
399
|
do
|
|
245
400
|
echo ""
|
|
246
|
-
gh_toc "$md" "$#" "$need_replace"
|
|
401
|
+
gh_toc "$md" "$#" "$need_replace" "$no_backup" "$no_footer" "$indent" "$skip_header"
|
|
247
402
|
done
|
|
248
403
|
|
|
249
404
|
echo ""
|
|
250
|
-
echo "Created by
|
|
405
|
+
echo "<!-- Created by https://github.com/ekalinin/github-markdown-toc -->"
|
|
251
406
|
}
|
|
252
407
|
|
|
253
408
|
#
|
|
254
409
|
# Entry point
|
|
255
410
|
#
|
|
256
|
-
gh_toc_app "$@"
|
|
411
|
+
gh_toc_app "$@"
|
package/package.json
CHANGED