Tk Library Source Code

View Ticket
Login
Ticket UUID: 601964
Title: cmdline::parseargs
Type: Patch Version: None
Submitter: edsuom Created on: 2002-08-29 16:33:08
Subsystem: cmdline Assigned To: andreas_kupries
Priority: 5 Medium Severity:
Status: Closed Last Modified: 2013-07-04 17:24:54
Resolution: Not Applicable Here Closed By:
    Closed on:
Description:
This interface is really getting annoying...
User Comments: andreas_kupries added on 2003-03-25 13:14:04:
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 ?

andreas_kupries added on 2002-09-07 03:53:08:
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.

edsuom added on 2002-08-29 23:33:09:

File Added - 30041: cmdline.tcl

Attachments: