Menu

#76 cmdline::parseargs

open
cmdline (4)
5
2002-08-29
2002-08-29
Ed Suominen
No

This interface is really getting annoying...

Discussion

  • Ed Suominen

    Ed Suominen - 2002-08-29

    Modified cmdline.tcl

     
  • Andreas Kupries

    Andreas Kupries - 2002-09-06

    Logged In: YES
    user_id=75003

    Please see the attached cmdline.tcl file, which
    includes a new proc "cmdline::parseargs".

    Here is a usage example:

    cmdline::parseargs \
    {startPath.arg {safeFlag} port.arg {host.arg 127.0.0.1}} \
    {stuff {morestuff 0}} $argv

    This gives the proc the following cmdline:
    -startPath <path> -port <port> ?-safeFlag? ?-host?
    stuff ?morestuff?

    It's been a tremendously valuable proc for my own work.
    Enjoy -- it's yours. If possible, I'd appreciate
    inclusion of the credit line in the file head (see
    attached file) but you can take it out if you want.

     
  • Andreas Kupries

    Andreas Kupries - 2003-03-25

    Logged In: YES
    user_id=75003

    Can you extend the usage example a bit ?

    I would like to see a complete procedure which calls
    'parseargs' to handle its own arguments.

    The reason I ask is that I am unsure about 'args' argument
    of 'parseargs'. Depending on how you intend to call the
    command the name is ok, or wrong. ... This may also factor
    into the 'singleVarFlag' code. and some other I saw later.
    I definitely need a complete example for a procedure here.
    Your example is for an application, using argv.

    Other comments and questions

    The automatic usage of -h|--help will interfere if a command
    has its own -h|--help to process.

    What happens if an option with an argument has no default
    value, and is not present in the argument list. Will a
    variable be set ? If yes, to what value. If not, what
    happens to an pre-existing variable of the same name.

    The command seems to assume that the variables it is setting
    in the callers context are scalars. What happens if a
    variable exists before the call, but is an array ?

    Do you have a testsuite for your command ?

    I have to admit, this [subst] construct at the end
    of the procedure looks a bit scary. I believe it is possible
    to rewrite that without subst, and using 'upvar' instead of
    'uplevel'. I won't start on this however until I have more
    understanding on how the command should work.

    I am also suspicious of this 'massage selected list if
    multiply escaped' code. Can you explain me in what situation
    it will kick in ?