forked from Youssef1313/ChessSharp
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathextract-vers.tcl
36 lines (33 loc) · 876 Bytes
/
extract-vers.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
# This file extracts and prints the VersionPrefix from a csproj file.
# Must be called like this: tclsh extract-vers.tcl xyz.csproj
proc readLines { fileName error } {
upvar $error err
if { [file exists $fileName] == 0 } {
set err ERR_FILE_NOT_FOUND
return 0
}
set f [open $fileName]
set lineList [read $f]
close $f
set ll [split $lineList \n]
set ll [lreplace $ll end end]
return $ll
}
proc getValueFromKey {lines key default} {
upvar $lines ll
foreach line $ll {
#puts "getValueFromIniLines 1.1 line=$line"
if { [regexp "<$key>(.*)</$key>" $line r r1] !=0 } {
#puts "getValueFromIniLines 1.2"
return $r1
}
}
return $default
}
set filename [lindex $argv 0]
#puts "LOOKING FOR VERS in $filename"
set err {}
set ll [readLines $filename err]
#puts LL=$ll
set vers [getValueFromKey ll {VersionPrefix} {0}]
puts $vers