-
Notifications
You must be signed in to change notification settings - Fork 4
/
update-readme.tcl
executable file
·39 lines (34 loc) · 993 Bytes
/
update-readme.tcl
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
#! /usr/bin/env jimsh
# Update jimhttp components' versions in README.md.
# Copyright (c) 2015-2016 D. Bohdan.
# License: MIT.
proc read-file filename {
set channel [open $filename]
set data [read $channel]
close $channel
return $data
}
proc write-file {filename data} {
set channel [open $filename w]
puts -nonewline $channel $data
close $channel
}
proc get-component-version filename {
set sourceCode [read-file $filename]
if {![regexp {variable version ([0-9]+\.[0-9]+\.[0-9]+)} $sourceCode \
_ version]} {
set version —
}
return $version
}
set updatedReadme {}
foreach line [split [read-file README.md] \n] {
if {[regexp {\| \[([a-z]+.tcl)\]\([a-z]+.tcl\)} $line _ filename]} {
set row [split $line |]
lset row 3 " [get-component-version $filename] "
lappend updatedReadme [join $row |]
} else {
lappend updatedReadme $line
}
}
write-file README.md [join $updatedReadme \n]