I have a code, if they match opt, then print opt-content
But result is not my expected:
How do I solved it?
I type:
$tclsh t.tcl -B bb -O oo
I got:
bb
bb
oo
--------
Non
--------
oo
bb
oo
--------
Non
--------
My code
package require cmdline
set parameters {
{B.arg "" "Build Dir"}
{O.arg "" "Output Dir"}
}
array set arg [cmdline::getoptions argv ${parameters}]
set requiredParameters {B O }
foreach iter ${requiredParameters} {
if {$arg(${iter}) == ""} {
error "Missing required parameter: -${iter}"
} else {
puts $arg(${iter})
puts $arg(B)
puts $arg(O)
puts "--------"
switch $arg(${iter}) {
$arg(B) {
puts $arg(${iter})
}
$arg(O) {
puts $arg(${iter})
}
default {
puts "Non"
}
}
puts "--------"
}
}
But result is not my expected:
How do I solved it?
I type:
$tclsh t.tcl -B bb -O oo
I got:
bb
bb
oo
--------
Non
--------
oo
bb
oo
--------
Non
--------
My code
package require cmdline
set parameters {
{B.arg "" "Build Dir"}
{O.arg "" "Output Dir"}
}
array set arg [cmdline::getoptions argv ${parameters}]
set requiredParameters {B O }
foreach iter ${requiredParameters} {
if {$arg(${iter}) == ""} {
error "Missing required parameter: -${iter}"
} else {
puts $arg(${iter})
puts $arg(B)
puts $arg(O)
puts "--------"
switch $arg(${iter}) {
$arg(B) {
puts $arg(${iter})
}
$arg(O) {
puts $arg(${iter})
}
default {
puts "Non"
}
}
puts "--------"
}
}