cmdr
Check-in [11f8b42694]
Not logged in
Bounty program for improvements to Tcl and certain Tcl packages.

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 Unified Diffs Ignore Whitespace Patch

Changes to vcommon.tcl.

34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
...
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
























124
125
126
127
128
129
130
namespace eval ::cmdr::validate {
    namespace export common
    namespace ensemble create
}

namespace eval ::cmdr::validate::common {
    namespace export \
	complete-enum complete-glob ok-directory \
	fail fail-unknown-thing fail-known-thing \
	lead-in
    namespace ensemble create
}

# # ## ### ##### ######## ############# #####################

debug define cmdr/validate/common
debug level  cmdr/validate/common
................................................................................
    # explicit request (level 10).
    debug.cmdr/validate/common {} 10

    if {$buffer eq {}} {
	return $choices
    }

    if {$nocase} {
	set buffer [string tolower $buffer]
    }

    set candidates {}
    foreach c $choices {
	if {![string match ${buffer}* $c]} continue
	lappend candidates $c
    }

























    debug.cmdr/validate/common {= [join $candidates "\n= "]} 10
    return $candidates
}

proc ::cmdr::validate::common::complete-glob {filter buffer} {
    debug.cmdr/validate/common {} 10






|
|
|







 







|








>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
...
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
namespace eval ::cmdr::validate {
    namespace export common
    namespace ensemble create
}

namespace eval ::cmdr::validate::common {
    namespace export \
	complete-enum complete-glob complete-substr \
	ok-directory lead-in fail fail-unknown-thing \
	fail-known-thing
    namespace ensemble create
}

# # ## ### ##### ######## ############# #####################

debug define cmdr/validate/common
debug level  cmdr/validate/common
................................................................................
    # explicit request (level 10).
    debug.cmdr/validate/common {} 10

    if {$buffer eq {}} {
	return $choices
    }

    if {($nocase eq "nocase") || $nocase} {
	set buffer [string tolower $buffer]
    }

    set candidates {}
    foreach c $choices {
	if {![string match ${buffer}* $c]} continue
	lappend candidates $c
    }

    debug.cmdr/validate/common {= [join $candidates "\n= "]} 10
    return $candidates
}

proc ::cmdr::validate::common::complete-substr {choices nocase buffer} {
    # As a helper function for validation printing anything
    # here would mix with the output of linenoise. Do that only on
    # explicit request (level 10).
    debug.cmdr/validate/common {} 10

    if {$buffer eq {}} {
	return $choices
    }

    if {($nocase eq "nocase") || $nocase} {
	set buffer [string tolower $buffer]
    }

    set candidates {}
    foreach c $choices {
	if {![string match *${buffer}* $c]} continue
	lappend candidates $c
    }

    debug.cmdr/validate/common {= [join $candidates "\n= "]} 10
    return $candidates
}

proc ::cmdr::validate::common::complete-glob {filter buffer} {
    debug.cmdr/validate/common {} 10