From: Andreas K. <and...@ac...> - 2014-12-01 18:32:58
|
Hello and thank you for the request and patch. My apologies for reacting only now. I was a bit distracted by office work and found only now the time to respond. Please note that our canonical place for the submission of requests, patches, etc is with our Ticket tracker at https://core.tcl.tk/tcllib/reportlist I have now created a ticket for your request, https://core.tcl.tk/tcllib/tktview/fef66e4953d95b97c3dda0bbe35f746b511e76dd and put all pertinent information into it. I added your email as contact information to ensure that you will be informed of any changes to this ticket. You might have already gotten the notification about the ticket creation and adding your patch as attachment. Do you have any test cases / examples which demonstrate the workings of the patched cmdline package ? These would be useful to have to make sure that future changes to the package will not break the feature. On Wed, Nov 26, 2014 at 8:28 PM, 尹剑虹 <yin...@16...> wrote: > tcllib/cmdline: add options format "[-]-opt[=val]" support. > > Q: Why add --options[=value] support? > A: I want to rewrite some tools completed by bash with tcl, > but cmdline can not support orig "--option=val" format, > so created this patch. > --- > modules/cmdline/cmdline.tcl | 15 +++++++++++++-- > 1 个文件被修改,插入 13 行(+),删除 2 行(-) > > diff --git a/modules/cmdline/cmdline.tcl b/modules/cmdline/cmdline.tcl > index e191b52..4803950 100644 > --- a/modules/cmdline/cmdline.tcl > +++ b/modules/cmdline/cmdline.tcl > @@ -120,8 +120,17 @@ proc ::cmdline::getKnownOpt {argvVar optstring optVar > valVar} { > set argsList [lrange $argsList 1 end] > } > > - "-*" { > + "-*" - > + "--*" { > set option [string range $arg 1 end] > + if [string equal [string range $option 0 0] "-"] {set option > [string range $arg 2 end]} > + > + # support for format: [-]-option=value > + set idx [string first "=" $option 1] > + if {$idx != -1} { > + set _val [string range $option [expr $idx+1] end] > + set option [string range $option 0 [expr $idx-1]] > + } > > if {[lsearch -exact $optstring $option] != -1} { > # Booleans are set to 1 when present > @@ -131,7 +140,9 @@ proc ::cmdline::getKnownOpt {argvVar optstring optVar > valVar} { > } elseif {[lsearch -exact $optstring "$option.arg"] != -1} { > set result 1 > set argsList [lrange $argsList 1 end] > - if {[llength $argsList] != 0} { > + if {[info exists _val]} { > + set value $_val > + } elseif {[llength $argsList] != 0} { > set value [lindex $argsList 0] > set argsList [lrange $argsList 1 end] > } else { > -- > 1.7.10.4 > > > > > ------------------------------------------------------------------------------ > Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server > from Actuate! Instantly Supercharge Your Business Reports and Dashboards > with Interactivity, Sharing, Native Excel Exports, App Integration & more > Get technology previously reserved for billion-dollar corporations, FREE > http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk > _______________________________________________ > Tcllib-devel mailing list > Tcl...@li... > https://lists.sourceforge.net/lists/listinfo/tcllib-devel > -- Andreas Kupries Senior Tcl Developer Code to Cloud: Smarter, Safer, Faster™ F: 778.786.1133 and...@ac..., http://www.activestate.com Learn about Stackato for Private PaaS: http://www.activestate.com/stackato |