cmdr
Check-in [11f8b42694]
Not logged in
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to tclconference@googlegroups.com
or submit via the online form by Sep 9.

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Added utility function for substring matching.
Timelines: family | ancestors | descendants | both | more-vtypes
Files: files | file ages | folders
SHA1:11f8b42694b4822df4671bf621f87bcbab07f6be
User & Date: aku 2015-04-07 06:09:00
Context
2015-04-17
05:50
Merge latest trunk changes (new docs). check-in: 534d48e23d user: aku tags: more-vtypes
2015-04-07
06:09
Added utility function for substring matching. check-in: 11f8b42694 user: aku tags: more-vtypes
2015-03-28
02:21
Fix year validation bug with misbehaving "clock scan" (more likely me misunderstanding it before) check-in: 75e8dc5ee8 user: aku tags: more-vtypes
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to vcommon.tcl.

    34     34   namespace eval ::cmdr::validate {
    35     35       namespace export common
    36     36       namespace ensemble create
    37     37   }
    38     38   
    39     39   namespace eval ::cmdr::validate::common {
    40     40       namespace export \
    41         -	complete-enum complete-glob ok-directory \
    42         -	fail fail-unknown-thing fail-known-thing \
    43         -	lead-in
           41  +	complete-enum complete-glob complete-substr \
           42  +	ok-directory lead-in fail fail-unknown-thing \
           43  +	fail-known-thing
    44     44       namespace ensemble create
    45     45   }
    46     46   
    47     47   # # ## ### ##### ######## ############# #####################
    48     48   
    49     49   debug define cmdr/validate/common
    50     50   debug level  cmdr/validate/common
................................................................................
   108    108       # explicit request (level 10).
   109    109       debug.cmdr/validate/common {} 10
   110    110   
   111    111       if {$buffer eq {}} {
   112    112   	return $choices
   113    113       }
   114    114   
   115         -    if {$nocase} {
          115  +    if {($nocase eq "nocase") || $nocase} {
   116    116   	set buffer [string tolower $buffer]
   117    117       }
   118    118   
   119    119       set candidates {}
   120    120       foreach c $choices {
   121    121   	if {![string match ${buffer}* $c]} continue
   122    122   	lappend candidates $c
   123    123       }
          124  +
          125  +    debug.cmdr/validate/common {= [join $candidates "\n= "]} 10
          126  +    return $candidates
          127  +}
          128  +
          129  +proc ::cmdr::validate::common::complete-substr {choices nocase buffer} {
          130  +    # As a helper function for validation printing anything
          131  +    # here would mix with the output of linenoise. Do that only on
          132  +    # explicit request (level 10).
          133  +    debug.cmdr/validate/common {} 10
          134  +
          135  +    if {$buffer eq {}} {
          136  +	return $choices
          137  +    }
          138  +
          139  +    if {($nocase eq "nocase") || $nocase} {
          140  +	set buffer [string tolower $buffer]
          141  +    }
          142  +
          143  +    set candidates {}
          144  +    foreach c $choices {
          145  +	if {![string match *${buffer}* $c]} continue
          146  +	lappend candidates $c
          147  +    }
   124    148   
   125    149       debug.cmdr/validate/common {= [join $candidates "\n= "]} 10
   126    150       return $candidates
   127    151   }
   128    152   
   129    153   proc ::cmdr::validate::common::complete-glob {filter buffer} {
   130    154       debug.cmdr/validate/common {} 10