cmdr
Check-in [463519edc6]
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:cmdr::parameter - Extended spec with description of option argument, if any. cmdr::help - Modified to make use of the new information in help texts.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:463519edc6123af3ac608ba27ab16ac25911322a
User & Date: andreask 2014-08-29 20:19:07
References
2014-11-26
23:12
Followup on [463519edc6]. Fixed missing handling of "arglabel" data in the json, tcl, and sql help formats. check-in: 9660d12cb0 user: andreask tags: trunk
Context
2014-09-10
20:21
Moved handling of option arguments in help to separate proc. Reworked the handling of global options to show arguments as well. Fixed sorting of section display when seeing options with arguments. check-in: f41f44de14 user: andreask tags: trunk
2014-08-29
20:19
cmdr::parameter - Extended spec with description of option argument, if any. cmdr::help - Modified to make use of the new information in help texts. check-in: 463519edc6 user: andreask tags: trunk
05:07
Tweaked output for help --full, added option arguments for options requiring them. check-in: 84658915a6 user: aku tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to help.tcl.

238
239
240
241
242
243
244
245


246

247
248
249
250
251
252
253
	foreach {oname ohelp} [::cmdr util dictsort $options] {
	    # Inspect the parameter and determine of the option
	    # requires an argument. If yes, suitably extend the
	    # definition key of the option list.
	    set pname [dict get $opt2para $oname]
	    set vt    [dict get $parameters $pname validator]
	    if {$vt ne "::cmdr::validate::boolean"} {
		# FUTURE: Make the argument label specifiable.


		set plabel [dict get $parameters $pname label]

		append oname " [string toupper $plabel]"
	    }

	    lappend onames $oname
	    lappend odefs  $ohelp
	}
	DefList $width $onames $odefs







|
>
>
|
>







238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
	foreach {oname ohelp} [::cmdr util dictsort $options] {
	    # Inspect the parameter and determine of the option
	    # requires an argument. If yes, suitably extend the
	    # definition key of the option list.
	    set pname [dict get $opt2para $oname]
	    set vt    [dict get $parameters $pname validator]
	    if {$vt ne "::cmdr::validate::boolean"} {
		if {[dict exists $parameters $pname arglabel]} {
		    set plabel [dict get $parameters $pname arglabel]
		} else {
		    set plabel [dict get $parameters $pname label]
		}
		append oname " [string toupper $plabel]"
	    }

	    lappend onames $oname
	    lappend odefs  $ohelp
	}
	DefList $width $onames $odefs

Changes to parameter.tcl.

44
45
46
47
48
49
50
51
52

53
54
55
56
57
58
59
...
152
153
154
155
156
157
158

159
160
161
162
163
164
165
...
236
237
238
239
240
241
242

243
244
245
246
247
248
249
...
274
275
276
277
278
279
280

281
282
283
284
285
286
287
...
313
314
315
316
317
318
319





320
321
322
323
324
325
326
....
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
## Definition

oo::class create ::cmdr::parameter {
    # # ## ### ##### ######## #############
    ## Lifecycle.

    constructor {theconfig order cmdline required defered name desc valuespec} {
	set myname  $name		; # [R1]
	set mylabel $name


	# Import the whole collection of parameters this one is a part
	# of into our namespace, as the fixed command "config", for
	# use by the various command prefixes (generate, validate,
	# when-complete), all of which will be run in our namespace
	# context.

................................................................................
	if {$myiscmdline} { return "option" }
	return "state"
    }

    # Identification and help. Add context name into it?
    method name        {} { return $myname }
    method label       {} { return $mylabel }


    method the-name {} {
	if {[my type] eq "option"} {
	    return [my flag]
	} else {
	    return $mylabel
	}
................................................................................
		    description $mydescription  \
		    documented  $myisdocumented \
		    flags       $myflags        \
		    generator   $mygenerate     \
		    interactive $myinteractive  \
		    isbool      [my isbool]     \
		    label       $mylabel        \

		    list        $myislist       \
		    ordered     $myisordered    \
		    presence    $myonlypresence \
		    prompt      $myprompt       \
		    required    $myisrequired   \
		    threshold   $mythreshold    \
		    type        [my type]       \
................................................................................
	    {alias         Alias} \
	    {default       Default} \
	    {defered       Defered} \
	    {generate      Generate} \
	    {immediate     Immediate} \
	    {interact      Interact} \
	    {label         Label} \

	    {list          List} \
	    {no-promotion  NoPromote} \
	    {optional      Optional} \
	    {presence      Presence} \
	    {test          Test} \
	    {undocumented  Undocumented} \
	    {validate      Validate} \
................................................................................
    # # ## ### ##### ######## #############
    ## Internal: Parameter DSL commands.

    method Label {name} {
	set mylabel $name
	return
    }






    method List {} {
	set myislist yes
	return
    }

    method Presence {} {
................................................................................
	    {*}$myvalidate release [self] $value
	}
	return
    }

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

    variable myname mylabel mydescription \
	myisordered myiscmdline myislist myisrequired \
	myinteractive myprompt mydefault myhasdefault \
	mywhencomplete mywhenset mygenerate myvalidate \
	myflags mythreshold myhasstring mystring \
	myhasvalue myvalue mylocker mystopinteraction \
	myisdocumented myonlypresence myisdefered \
	myisundefined mynopromote

    # # ## ### ##### ######## #############
}

# # ## ### ##### ######## ############# #####################
## Ready
package provide cmdr::parameter 1.2







|
|
>







 







>







 







>







 







>







 







>
>
>
>
>







 







|













|
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
...
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
...
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
...
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
...
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
....
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
## Definition

oo::class create ::cmdr::parameter {
    # # ## ### ##### ######## #############
    ## Lifecycle.

    constructor {theconfig order cmdline required defered name desc valuespec} {
	set myname     $name		; # [R1]
	set mylabel    $name
	set myarglabel $name

	# Import the whole collection of parameters this one is a part
	# of into our namespace, as the fixed command "config", for
	# use by the various command prefixes (generate, validate,
	# when-complete), all of which will be run in our namespace
	# context.

................................................................................
	if {$myiscmdline} { return "option" }
	return "state"
    }

    # Identification and help. Add context name into it?
    method name        {} { return $myname }
    method label       {} { return $mylabel }
    method arglabel    {} { return $myarglabel }

    method the-name {} {
	if {[my type] eq "option"} {
	    return [my flag]
	} else {
	    return $mylabel
	}
................................................................................
		    description $mydescription  \
		    documented  $myisdocumented \
		    flags       $myflags        \
		    generator   $mygenerate     \
		    interactive $myinteractive  \
		    isbool      [my isbool]     \
		    label       $mylabel        \
		    arglabel    $myarglabel     \
		    list        $myislist       \
		    ordered     $myisordered    \
		    presence    $myonlypresence \
		    prompt      $myprompt       \
		    required    $myisrequired   \
		    threshold   $mythreshold    \
		    type        [my type]       \
................................................................................
	    {alias         Alias} \
	    {default       Default} \
	    {defered       Defered} \
	    {generate      Generate} \
	    {immediate     Immediate} \
	    {interact      Interact} \
	    {label         Label} \
	    {argument      ArgLabel} \
	    {list          List} \
	    {no-promotion  NoPromote} \
	    {optional      Optional} \
	    {presence      Presence} \
	    {test          Test} \
	    {undocumented  Undocumented} \
	    {validate      Validate} \
................................................................................
    # # ## ### ##### ######## #############
    ## Internal: Parameter DSL commands.

    method Label {name} {
	set mylabel $name
	return
    }

    method ArgLabel {name} {
	set myarglabel $name
	return
    }

    method List {} {
	set myislist yes
	return
    }

    method Presence {} {
................................................................................
	    {*}$myvalidate release [self] $value
	}
	return
    }

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

    variable myname mylabel myarglabel mydescription \
	myisordered myiscmdline myislist myisrequired \
	myinteractive myprompt mydefault myhasdefault \
	mywhencomplete mywhenset mygenerate myvalidate \
	myflags mythreshold myhasstring mystring \
	myhasvalue myvalue mylocker mystopinteraction \
	myisdocumented myonlypresence myisdefered \
	myisundefined mynopromote

    # # ## ### ##### ######## #############
}

# # ## ### ##### ######## ############# #####################
## Ready
package provide cmdr::parameter 1.3