cmdr
Check-in [7fc0be3870]
Not logged in

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

Overview
Comment:officer - Modified method extend to return the new command instance, for dynamic re-configuration post-creation.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 7fc0be38702632bebe3f0b767b688a0476e9542c
User & Date: aku 2014-02-06 05:04:46.080
Context
2014-02-06
05:05
Fixed problems with the generation of categorized help when encountering sections with sub-sections, but no commands check-in: 11fff41159 user: aku tags: trunk
05:04
officer - Modified method extend to return the new command instance, for dynamic re-configuration post-creation. check-in: 7fc0be3870 user: aku tags: trunk
2014-01-30
18:09
Fixed command scope problems in "extend". check-in: f1bb89c324 user: andreask tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to officer.tcl.
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
    # automatically as needed.

    method extend {path arguments action} {
	if {[llength $path] == 1} {
	    # Reached the bottom of the recursion.
	    # Generate the private handling arguments and action.
	    set cmd [lindex $path 0]
	    my Private $cmd $arguments $action
	    return
	}

	# Recurse, creating the intermediate officers as needed.
	set path [lassign $path cmd]
	if {![my has $cmd]} {
	    my Officer $cmd {}
	}

	[my lookup $cmd] extend $path $arguments $action
	return
    }

    # # ## ### ##### ######## #############
    ## Implementation of the action specification language.

    # common      => set          (super cmdr::actor)
    # description => description: (super cmdr::actor)







|
<









<







208
209
210
211
212
213
214
215

216
217
218
219
220
221
222
223
224

225
226
227
228
229
230
231
    # automatically as needed.

    method extend {path arguments action} {
	if {[llength $path] == 1} {
	    # Reached the bottom of the recursion.
	    # Generate the private handling arguments and action.
	    set cmd [lindex $path 0]
	    return [my Private $cmd $arguments $action]

	}

	# Recurse, creating the intermediate officers as needed.
	set path [lassign $path cmd]
	if {![my has $cmd]} {
	    my Officer $cmd {}
	}

	[my lookup $cmd] extend $path $arguments $action

    }

    # # ## ### ##### ######## #############
    ## Implementation of the action specification language.

    # common      => set          (super cmdr::actor)
    # description => description: (super cmdr::actor)
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300

	# Propagate error handler.
	$handler ehandler $myhandler

	lappend mychildren $handler

	my Def $name $handler
	return
    }

    method Def {name handler} {
	# Make an action known to the dispatcher.
	dict set mymap last $name
	dict set mymap   a,$name $handler
	lappend mycommands $name







|







284
285
286
287
288
289
290
291
292
293
294
295
296
297
298

	# Propagate error handler.
	$handler ehandler $myhandler

	lappend mychildren $handler

	my Def $name $handler
	return $handler
    }

    method Def {name handler} {
	# Make an action known to the dispatcher.
	dict set mymap last $name
	dict set mymap   a,$name $handler
	lappend mycommands $name