Passing "dash" Options to a procedure



I've been looking for a way to write my TCL procedures to accept "dash"
options, but I haven't had any luck.

As an example, I'm trying to take something like this:

sub my_proc { {var1 "foo"} {var2 "bar"}} {
puts $var1
puts $var2
}
which does:
>my_proc
foo
bar
>my_proc cat
cat
bar

and turn it's interface into this
>my_proc -var2 dog
foo
dog
>
So now it will still have it's defaults, but I can override var2 without
having to specify var1.
Does anyone have any ideas how to do this? I'm sure it's been solved before.
If so, does anyone know of a package that's out there that can handle this
type of option passing?


.



Relevant Pages

  • Re: Sed replace from another file
    ... > $cat foo ... Looks like you're trying to do a match and merge to basically sequence bar ... like foo. ... Otherwise, you'll need awk, perl or some bash script to sort bar, colrm 1 ...
    (linux.redhat)
  • Re: newbie question - how to use multiple source files
    ... second file, and I want to create an object from the first class, ... thufir@arrakis ~/Desktop/foobar $ cat driver.rb ... class Foo ... class Bar ...
    (comp.lang.ruby)
  • Re: from __future__ import absolute_import ?
    ... If there are two modules 'foo', one at the toplevel and the other inside ... $ cat bar/absolute.py ... print "in bar" ... in the foot and should be avoided with or without absolute import. ...
    (comp.lang.python)
  • Re: Better one liner to sum a column?
    ... $ cat example_data ... As a relative newby I tried inject which seemed cool but ... foo 100 ... bar 32 ...
    (comp.lang.ruby)
  • Re: Python Macros
    ... I'd think that, in most cases, if foo doesn't understand bar(), then it ... To go back to the dog.fetch(cat) example -- if the dog doesn't ... would understand how to fetch a cat, ... don't understand go to my owner," while the calling code has a good ...
    (comp.lang.python)