Am 28.05.2005 um 14:19 schrieb Stephen Deasey:
ns_parseargs {{-eightbit flag} {-foo flag} args}
How do you distinguish between -eightbit which is a boolean flag, and
-foo which is an option with a default string value of 'flag'?
Here is how:
ns_parseargs {{{-eightbit flag}} {-foo flag} args}
The first argument of the above spec is:
{{-eightbit flag}}
which is a one-element list.
Generally you'd have:
{{spec} {spec} {spec} args}
where "spec" is:
{option value}
where option is:
{-variable type ?type_specific_part?}
The "type_specific_part" whould be a choice-list for "oneof" type,
for example.
This is just a nested-list exercise. It is Tcl-natural and can become
difficult to write with all those curly braces, but that's the price
of the flexibility.
I don't know that it makes much sense to supply a default for boolean
flags. In that case you probably want to invert the sense of the flag
name: -nofoo.
There is no sense in supplying defaults for boolean flags, but the
syntax would/must allow it (i.e. special case).
Zoran