1 | # portquery-variants.tcl |
---|
2 | |
---|
3 | package provide portquery-variants 1.0 |
---|
4 | |
---|
5 | set com.apple.query-variants [target_new com.apple.query-variants query-variants_main] |
---|
6 | target_runtype ${com.apple.query-variants} always |
---|
7 | target_provides ${com.apple.query-variants} query-variants |
---|
8 | target_requires ${com.apple.query-variants} main |
---|
9 | |
---|
10 | proc query-variants_main {args} { |
---|
11 | global portname |
---|
12 | |
---|
13 | # search for port |
---|
14 | set res [dportsearch ^$portname$] |
---|
15 | |
---|
16 | # an array is better than a list for this imho |
---|
17 | array set portinfo [lindex $res 1] |
---|
18 | |
---|
19 | # if this fails the port doesn't have any variants |
---|
20 | if {[catch {set portvariants $portinfo(variants)} result]} { |
---|
21 | puts "$portname has no variants" |
---|
22 | exit 1 |
---|
23 | } |
---|
24 | |
---|
25 | # print out all the variants |
---|
26 | for {set i 0} {$i < [llength $portvariants]} {incr i} { |
---|
27 | puts "[lindex $portvariants $i]" |
---|
28 | } |
---|
29 | } |
---|
30 | |
---|