cmdr
Check-in [a81d6b881f]
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 [email protected]
or submit via the online form by Sep 9.

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

Overview
Comment:Added defered/immediate distinction for parameters, with state defaulting to defered, and the others as immediate. Updated tests. Bumped version to 0.3.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: a81d6b881f27c328b95cfb41ddd457b4310ed64f
User & Date: andreask 2013-08-02 21:33:16
Context
2013-08-02
22:07
Added a bit more debug narrative in the help support check-in: 0472dca221 user: andreask tags: trunk
21:33
Added defered/immediate distinction for parameters, with state defaulting to defered, and the others as immediate. Updated tests. Bumped version to 0.3. check-in: a81d6b881f user: andreask tags: trunk
2013-07-25
20:22
AS bug 99702. Fix handling of argument queue in code for splat. Did not take changing result type of struct::queue get into account. check-in: 02ba0ccd02 user: andreask tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to actor.tcl.

309
310
311
312
313
314
315
316
    ##
    # # ## ### ##### ######## #############
}

# # ## ### ##### ######## ############# #####################
## Ready
package provide cmdr::actor 0.2






|
309
310
311
312
313
314
315
316
    ##
    # # ## ### ##### ######## #############
}

# # ## ### ##### ######## ############# #####################
## Ready
package provide cmdr::actor 0.3

Changes to cmdr.tcl.

71
72
73
74
75
76
77
78
proc ::cmdr::interactive? {} {
    variable interactive
    return  $interactive
}

# # ## ### ##### ######## ############# #####################
## Ready
package provide cmdr 0.2






|
71
72
73
74
75
76
77
78
proc ::cmdr::interactive? {} {
    variable interactive
    return  $interactive
}

# # ## ### ##### ######## ############# #####################
## Ready
package provide cmdr 0.3

Changes to config.tcl.

211
212
213
214
215
216
217
218






219
220
221
222
223
224
225
226
227
228
229





230
231
232
233
234
235
236
...
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
....
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
....
1209
1210
1211
1212
1213
1214
1215

1216
1217
1218
1219
1220
1221
1222
....
1269
1270
1271
1272
1273
1274
1275
1276
	    set names [linsert [join [lsort -dict [my options]] {, }] end-1 or]
	    return -code error -errorcode {CMDR CONFIG PARAMETER UNKNOWN} \
		"Got \"$name\", expected option name, one of $names"
	}
	return [dict get $myoption $name]
    }

    method force {{allowinteract 1}} {






	debug.cmdr/config {recursive=$myinforce}
	# Define the values of all parameters.
	# Done in order of declaration.
	# Any dependencies between parameter can be handled by proper
	# declaration order.

	if {$myinforce} return
	set myinforce yes

	foreach name $mynames {
	    set para [dict get $mymap $name]





	    if {!$allowinteract} {
		$para dontinteract
	    }
	    try {
		$para value
	    } trap {CMDR PARAMETER UNDEFINED} {e o} {
		# Ignore when a parameter was not defined.
................................................................................
    method Interactive {} {
	debug.cmdr/config {}
	set myinteractive 1
	return
    }

    # Parameter definition itself.
    #       order, cmdline, required (O C R) name ?spec?
    forward Input  my DefineParameter 1 1 1
    forward Option my DefineParameter 0 1 0
    forward State  my DefineParameter 0 0 1

    method DefineParameter {
			    order cmdline required
			    name desc {spec {}}
			} {
	debug.cmdr/config {}

	upvar 1 splat splat
	if {$splat && $order} {
	    return -code error -errorcode {CMDR CONFIG SPLAT ORDER} \
		"A splat must be the last argument in the specification"
	}

	my ValidateAsUnknown $name

	# Create and initialize handler.
	set para [cmdr::parameter create param_$name [self] \
		      $order $cmdline $required \
		      $name $desc $spec]

	# Map parameter name to handler object.
	dict set mymap $name $para

	# And a second map, user-visible parameters only,
	# i.e. available on the cmdline, and documented.
................................................................................
	set labels [cmdr util padr $plist]
	set blank  [string repeat { } [string length [lindex $labels 0]]]

	# Recalculate the value of changed parameters. (They have
	# 'forgotten' their value due to 'set'). We disallow interaction
	# for parameters who would normally do this to gather information
	# from the user.
	my force 0

	set text {}
	set alldefined 1
	set somebad    0
	foreach label $labels para $plist {
	    set para [my lookup $para]

................................................................................
		append label [expr {[$para cmdline]    ? "c":"-"}]
		append label [expr {[$para list]       ? "L":"-"}]
		append label [expr {[$para presence]   ? "P":"-"}]
		append label [expr {[$para documented] ? "d":"-"}]
		append label [expr {[$para isbool]     ? "B":"-"}]
		append label [expr {[$para hasdefault] ? "D":"-"}]
		append label [expr {[$para defined?]   ? "!":"-"}]


		append label [expr {[$para required] ? "/.." : [$para threshold] < 0 ? "/pt":"/th"}]

		append label ")"
		set sfx {              }
	    } else {
		append label [expr {[$para list]       ? " L":"  "}]
................................................................................
    }

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

# # ## ### ##### ######## ############# #####################
## Ready
package provide cmdr::config 0.2






|
>
>
>
>
>
>











>
>
>
>
>







 







|
|
|
|


|
|
|












|







 







|







 







>







 







|
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
...
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
....
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
....
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
....
1281
1282
1283
1284
1285
1286
1287
1288
	    set names [linsert [join [lsort -dict [my options]] {, }] end-1 or]
	    return -code error -errorcode {CMDR CONFIG PARAMETER UNKNOWN} \
		"Got \"$name\", expected option name, one of $names"
	}
	return [dict get $myoption $name]
    }

    method force {{allowinteract yes} {forcedefered no}} {
	debug.cmdr/config {}
	my Force $allowinteract $forcedefered
	return
    }

    method Force {allowinteract forcedefered} {
	debug.cmdr/config {recursive=$myinforce}
	# Define the values of all parameters.
	# Done in order of declaration.
	# Any dependencies between parameter can be handled by proper
	# declaration order.

	if {$myinforce} return
	set myinforce yes

	foreach name $mynames {
	    set para [dict get $mymap $name]

	    # Ignore parameters which defer value generation until
	    # actual use, except if we are forced to compute them.
	    if {!$forcedefered && [$para defered]} continue

	    if {!$allowinteract} {
		$para dontinteract
	    }
	    try {
		$para value
	    } trap {CMDR PARAMETER UNDEFINED} {e o} {
		# Ignore when a parameter was not defined.
................................................................................
    method Interactive {} {
	debug.cmdr/config {}
	set myinteractive 1
	return
    }

    # Parameter definition itself.
    # order, cmdline, required, defered (O C R D) name ?spec?
    forward Input     my DefineParameter 1 1 1 0
    forward Option    my DefineParameter 0 1 0 0
    forward State     my DefineParameter 0 0 1 1

    method DefineParameter {
	order cmdline required defered
	name desc {spec {}}
    } {
	debug.cmdr/config {}

	upvar 1 splat splat
	if {$splat && $order} {
	    return -code error -errorcode {CMDR CONFIG SPLAT ORDER} \
		"A splat must be the last argument in the specification"
	}

	my ValidateAsUnknown $name

	# Create and initialize handler.
	set para [cmdr::parameter create param_$name [self] \
		      $order $cmdline $required $defered \
		      $name $desc $spec]

	# Map parameter name to handler object.
	dict set mymap $name $para

	# And a second map, user-visible parameters only,
	# i.e. available on the cmdline, and documented.
................................................................................
	set labels [cmdr util padr $plist]
	set blank  [string repeat { } [string length [lindex $labels 0]]]

	# Recalculate the value of changed parameters. (They have
	# 'forgotten' their value due to 'set'). We disallow interaction
	# for parameters who would normally do this to gather information
	# from the user.
	my Force 0 0

	set text {}
	set alldefined 1
	set somebad    0
	foreach label $labels para $plist {
	    set para [my lookup $para]

................................................................................
		append label [expr {[$para cmdline]    ? "c":"-"}]
		append label [expr {[$para list]       ? "L":"-"}]
		append label [expr {[$para presence]   ? "P":"-"}]
		append label [expr {[$para documented] ? "d":"-"}]
		append label [expr {[$para isbool]     ? "B":"-"}]
		append label [expr {[$para hasdefault] ? "D":"-"}]
		append label [expr {[$para defined?]   ? "!":"-"}]
		append label [expr {[$para defered]    ? ">":"-"}]

		append label [expr {[$para required] ? "/.." : [$para threshold] < 0 ? "/pt":"/th"}]

		append label ")"
		set sfx {              }
	    } else {
		append label [expr {[$para list]       ? " L":"  "}]
................................................................................
    }

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

# # ## ### ##### ######## ############# #####################
## Ready
package provide cmdr::config 0.3

Changes to help.tcl.

347
348
349
350
351
352
353
354
    } else {
	return {}
    }
}

# # ## ### ##### ######## ############# #####################
## Ready
package provide cmdr::help 0.2






|
347
348
349
350
351
352
353
354
    } else {
	return {}
    }
}

# # ## ### ##### ######## ############# #####################
## Ready
package provide cmdr::help 0.3

Changes to officer.tcl.

612
613
614
615
616
617
618
619
	myreplexit myhandler

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

# # ## ### ##### ######## ############# #####################
## Ready
package provide cmdr::officer 0.2






|
612
613
614
615
616
617
618
619
	myreplexit myhandler

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

# # ## ### ##### ######## ############# #####################
## Ready
package provide cmdr::officer 0.3

Changes to parameter.tcl.

91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
...
118
119
120
121
122
123
124

125
126
127
128
129
130
131
...
192
193
194
195
196
197
198


199
200
201
202
203
204
205
...
242
243
244
245
246
247
248

249
250

251
252
253
254
255
256
257
...
323
324
325
326
327
328
329














330
331
332
333
334
335
336
....
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
	return -code error -errorcode {CMDR PARAMETER BAD CONTEXT} \
	    "Bad context, no config found in the stack."
    }

    # # ## ### ##### ######## #############
    ## Lifecycle.

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

	# 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-defined), all of which will be run in our namespace
	# context.
................................................................................
	# nonsense.

	set mydescription $desc		; # [R2]

	set myisordered   $order	; # [R3,4,5,6]
	set myiscmdline   $cmdline	; # [R3,4,5,6]
	set myisrequired  $required	; # [R7,8,9,10]


	my C1_StateIsUnordered
	my C2_OptionIsOptional
	my C3_StateIsRequired

	set mystopinteraction no ;# specified interaction is not suppressed.
	set myislist       no ;# scalar vs list parameter
................................................................................
	return [expr {[dict get $myflags $option] eq "primary"}]
    }

    # Core classification properties
    method ordered      {} { return $myisordered }
    method cmdline      {} { return $myiscmdline }
    method required     {} { return $myisrequired }


    method list         {} { return $myislist }
    method presence     {} { return $myonlypresence }
    method documented   {} { return $myisdocumented }
    method isbool       {} { return [expr {$myvalidate eq "::cmdr::validate::boolean"}] }
    method locker       {} { return $mylocker }

    # Alternate sources for the parameter value.
................................................................................

	set myflags {}

	# Import the DSL commands to translate the specification.
	link \
	    {alias        Alias} \
	    {default      Default} \

	    {generate     Generate} \
	    {interact     Interact} \

	    {list         List} \
	    {presence     Presence} \
	    {optional     Optional} \
	    {test         Test} \
	    {undocumented Undocumented} \
	    {validate     Validate} \
	    {when-defined WhenDefined} \
................................................................................
	# change.
	set myinteractive yes
	my C6_RequiredArgumentForbiddenInteract
	if {$prompt eq {}} return ; # keep standard prompt
	set myprompt $prompt
	return
    }















    method Default {value} {
	my C9_PresenceDefaultConflict
	# Check most of the relevant constraint(s) after making the
	# change. That is easier than re-casting the expressions for
	# the proposed change.
	set myhasdefault yes
................................................................................

    variable myconfig myname mydescription \
	myisordered myiscmdline myislist myisrequired \
	myinteractive myprompt mydefault myhasdefault \
	mywhendef mywhenset mygenerate myvalidate \
	myflags mythreshold myhasstring mystring \
	myhasvalue myvalue mylocker mystopinteraction \
	myisdocumented myonlypresence

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

# # ## ### ##### ######## ############# #####################
## Ready
package provide cmdr::parameter 0.2






|







 







>







 







>
>







 







>


>







 







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







 







|






|
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
...
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
...
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
...
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
...
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
....
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
	return -code error -errorcode {CMDR PARAMETER BAD CONTEXT} \
	    "Bad context, no config found in the stack."
    }

    # # ## ### ##### ######## #############
    ## Lifecycle.

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

	# 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-defined), all of which will be run in our namespace
	# context.
................................................................................
	# nonsense.

	set mydescription $desc		; # [R2]

	set myisordered   $order	; # [R3,4,5,6]
	set myiscmdline   $cmdline	; # [R3,4,5,6]
	set myisrequired  $required	; # [R7,8,9,10]
	set myisdefered   $defered      ; # [R ???]

	my C1_StateIsUnordered
	my C2_OptionIsOptional
	my C3_StateIsRequired

	set mystopinteraction no ;# specified interaction is not suppressed.
	set myislist       no ;# scalar vs list parameter
................................................................................
	return [expr {[dict get $myflags $option] eq "primary"}]
    }

    # Core classification properties
    method ordered      {} { return $myisordered }
    method cmdline      {} { return $myiscmdline }
    method required     {} { return $myisrequired }
    method defered      {} { return $myisdefered }

    method list         {} { return $myislist }
    method presence     {} { return $myonlypresence }
    method documented   {} { return $myisdocumented }
    method isbool       {} { return [expr {$myvalidate eq "::cmdr::validate::boolean"}] }
    method locker       {} { return $mylocker }

    # Alternate sources for the parameter value.
................................................................................

	set myflags {}

	# Import the DSL commands to translate the specification.
	link \
	    {alias        Alias} \
	    {default      Default} \
	    {defered      Defered} \
	    {generate     Generate} \
	    {interact     Interact} \
	    {immediate    Immediate} \
	    {list         List} \
	    {presence     Presence} \
	    {optional     Optional} \
	    {test         Test} \
	    {undocumented Undocumented} \
	    {validate     Validate} \
	    {when-defined WhenDefined} \
................................................................................
	# change.
	set myinteractive yes
	my C6_RequiredArgumentForbiddenInteract
	if {$prompt eq {}} return ; # keep standard prompt
	set myprompt $prompt
	return
    }

    method Defered {} {
	# Consider adding checks against current state, prevent use
	# of calls not making an actual change.
	set myisdefered yes
	return
    }

    method Immediate {} {
	# Consider adding checks against current state, prevent use
	# of calls not making an actual change.
	set myisdefered no
	return
    }

    method Default {value} {
	my C9_PresenceDefaultConflict
	# Check most of the relevant constraint(s) after making the
	# change. That is easier than re-casting the expressions for
	# the proposed change.
	set myhasdefault yes
................................................................................

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

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

# # ## ### ##### ######## ############# #####################
## Ready
package provide cmdr::parameter 0.3

Changes to private.tcl.

122
123
124
125
126
127
128
129

130
131
132
133
134
135
136
...
163
164
165
166
167
168
169
170
	    }
	    if {![config interact]} return
	}

	debug.cmdr/private {complete values}

	# Define all parameters now, resolving defaults, validating
	# the values, etc.

	config force

	debug.cmdr/private {execute}
	# Call actual command, hand it the filled configuration.
	{*}$mycmd $myconfig 
    }

................................................................................
    variable myarguments mycmd myinit myconfig myhandler

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

# # ## ### ##### ######## ############# #####################
## Ready
package provide cmdr::private 0.2






|
>







 







|
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
...
164
165
166
167
168
169
170
171
	    }
	    if {![config interact]} return
	}

	debug.cmdr/private {complete values}

	# Define all parameters now, resolving defaults, validating
	# the values, etc. Except for the 'defered' parameters. By
	# default this are only the 'state' parameters.
	config force

	debug.cmdr/private {execute}
	# Call actual command, hand it the filled configuration.
	{*}$mycmd $myconfig 
    }

................................................................................
    variable myarguments mycmd myinit myconfig myhandler

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

# # ## ### ##### ######## ############# #####################
## Ready
package provide cmdr::private 0.3

Changes to tests/cmdr.test.

6
7
8
9
10
11
12



13
14



15
16
17
18
19
20
21
kt check tcltest 2

kt require support TclOO
kt require support oo::util 1.2
kt require support struct::queue
kt require support try
kt require support lambda



kt require support string::token::shell
kt require support textutil::adjust




kt local   support cmdr::util
kt local   support cmdr::help

kt local   support cmdr::parameter
kt local   support cmdr::config
kt local   support cmdr::actor






>
>
>
|

>
>
>







6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
kt check tcltest 2

kt require support TclOO
kt require support oo::util 1.2
kt require support struct::queue
kt require support try
kt require support lambda
kt require support linenoise
kt require support linenoise::repl
kt require support linenoise::facade
kt require support string::token::shell 1.1
kt require support textutil::adjust
kt require support term::ansi::code::ctrl
kt require support debug
kt require support debug::caller

kt local   support cmdr::util
kt local   support cmdr::help

kt local   support cmdr::parameter
kt local   support cmdr::config
kt local   support cmdr::actor

Changes to tests/parameter.tests.

41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
..
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
...
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
...
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
...
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
...
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
...
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
...
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
...
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
...
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
...
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
...
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
...
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
...
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
...
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
...
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
...
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
...
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
...
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
...
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
...
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
...
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
...
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
...
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
...
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
...
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
...
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
...
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
...
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
...
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
...
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
...
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
        map --no --> (--no-A)
        map --no- --> (--no-A)
        map --no-A --> (--no-A)
        map -A --> (-A)
        map -X --> (-X)
        para (A) {
            description: '-'
            !ordered, cmdline, !splat, !required, !interact
            default: 'no'
            flags [--no-A -A -X]
            ge ()
            va (::cmdr::validate::boolean)
            wd ()
        }
    }
................................................................................
        map --no --> (--no-A)
        map --no- --> (--no-A)
        map --no-A --> (--no-A)
        map -A --> (-A)
        map -X --> (-X)
        para (no-A) {
            description: '-'
            !ordered, cmdline, !splat, !required, !interact
            default: 'no'
            flags [--no-A -A -X]
            ge ()
            va (::cmdr::validate::boolean)
            wd ()
        }
    }
................................................................................
    NiceParamSpec input { optional ; default 0 }
} -result {
    foo bar = {
        description: ''
        argument (A)
        para (A) {
            description: '-'
            ordered, cmdline, !splat, !required, !interact
            default: '0'
            mode=threshold 0
            flags []
            ge ()
            va (::cmdr::validate::boolean)
            wd ()
        }
................................................................................
    NiceParamSpec input { optional ; default 2 }
} -result {
    foo bar = {
        description: ''
        argument (A)
        para (A) {
            description: '-'
            ordered, cmdline, !splat, !required, !interact
            default: '2'
            mode=threshold 0
            flags []
            ge ()
            va (::cmdr::validate::integer)
            wd ()
        }
................................................................................
    NiceParamSpec input { optional ; default X }
} -result {
    foo bar = {
        description: ''
        argument (A)
        para (A) {
            description: '-'
            ordered, cmdline, !splat, !required, !interact
            default: 'X'
            mode=threshold 0
            flags []
            ge ()
            va (::cmdr::validate::identity)
            wd ()
        }
................................................................................
        map --n --> (--no-A)
        map --no --> (--no-A)
        map --no- --> (--no-A)
        map --no-A --> (--no-A)
        map -A --> (-A)
        para (A) {
            description: '-'
            !ordered, cmdline, !splat, !required, !interact
            default: '0'
            flags [--no-A -A]
            ge ()
            va (::cmdr::validate::boolean)
            wd ()
        }
    }
................................................................................
} -result {
    foo bar = {
        description: ''
        option (-A) = A
        map -A --> (-A)
        para (A) {
            description: '-'
            !ordered, cmdline, !splat, !required, !interact
            default: '2'
            flags [-A]
            ge ()
            va (::cmdr::validate::integer)
            wd ()
        }
    }
................................................................................
} -result {
    foo bar = {
        description: ''
        option (-A) = A
        map -A --> (-A)
        para (A) {
            description: '-'
            !ordered, cmdline, !splat, !required, !interact
            default: 'X'
            flags [-A]
            ge ()
            va (::cmdr::validate::identity)
            wd ()
        }
    }
................................................................................
test cmdr-parameter-2.9 {parameter DSL, state, default, auto validate boolean} -body {
    NiceParamSpec state { default 0 }
} -result {
    foo bar = {
        description: ''
        para (A) {
            description: '-'
            !ordered, !cmdline, !splat, required, !interact
            default: '0'
            flags []
            ge ()
            va (::cmdr::validate::boolean)
            wd ()
        }
    }
................................................................................
test cmdr-parameter-2.10 {parameter DSL, state, default, auto validate integer} -body {
    NiceParamSpec state { default 2 }
} -result {
    foo bar = {
        description: ''
        para (A) {
            description: '-'
            !ordered, !cmdline, !splat, required, !interact
            default: '2'
            flags []
            ge ()
            va (::cmdr::validate::integer)
            wd ()
        }
    }
................................................................................
test cmdr-parameter-2.11 {parameter DSL, state, default, auto validate identity} -body {
    NiceParamSpec state { default X }
} -result {
    foo bar = {
        description: ''
        para (A) {
            description: '-'
            !ordered, !cmdline, !splat, required, !interact
            default: 'X'
            flags []
            ge ()
            va (::cmdr::validate::identity)
            wd ()
        }
    }
................................................................................
    NiceParamSpec input { optional ; generate G }
} -result {
    foo bar = {
        description: ''
        argument (A)
        para (A) {
            description: '-'
            ordered, cmdline, !splat, !required, !interact
            no default
            mode=threshold 0
            flags []
            ge (G)
            va (::cmdr::validate::identity)
            wd ()
        }
................................................................................
} -result {
    foo bar = {
        description: ''
        option (-A) = A
        map -A --> (-A)
        para (A) {
            description: '-'
            !ordered, cmdline, !splat, !required, !interact
            no default
            flags [-A]
            ge (G)
            va (::cmdr::validate::identity)
            wd ()
        }
    }
................................................................................
test cmdr-parameter-3.4 {parameter DSL, state, generate} -body {
    NiceParamSpec state { generate G }
} -result {
    foo bar = {
        description: ''
        para (A) {
            description: '-'
            !ordered, !cmdline, !splat, required, !interact
            no default
            flags []
            ge (G)
            va (::cmdr::validate::identity)
            wd ()
        }
    }
................................................................................
    NiceParamSpec input { optional ; interact }
} -result {
    foo bar = {
        description: ''
        argument (A)
        para (A) {
            description: '-'
            ordered, cmdline, !splat, !required, interact
            default: ''
            prompt: 'Enter A:'
            mode=threshold 0
            flags []
            ge ()
            va (::cmdr::validate::identity)
            wd ()
        }
    }
................................................................................
    NiceParamSpec input { optional ; interact HERE }
} -result {
    foo bar = {
        description: ''
        argument (A)
        para (A) {
            description: '-'
            ordered, cmdline, !splat, !required, interact
            default: ''
            prompt: 'HERE'
            mode=threshold 0
            flags []
            ge ()
            va (::cmdr::validate::identity)
            wd ()
................................................................................
        map --n --> (--no-A)
        map --no --> (--no-A)
        map --no- --> (--no-A)
        map --no-A --> (--no-A)
        map -A --> (-A)
        para (A) {
            description: '-'
            !ordered, cmdline, !splat, !required, interact
            default: 'no'
            prompt: 'Enter A:'
            flags [--no-A -A]
            ge ()
            va (::cmdr::validate::boolean)
            wd ()
        }
    }
}
................................................................................
test cmdr-parameter-4.5 {parameter DSL, state, interact} -body {
    NiceParamSpec state { interact }
} -result {
    foo bar = {
        description: ''
        para (A) {
            description: '-'
            !ordered, !cmdline, !splat, required, interact
            default: ''
            prompt: 'Enter A:'
            flags []
            ge ()
            va (::cmdr::validate::identity)
            wd ()
        }
    }
}
................................................................................
    NiceParamSpec input { list }
} -result {
    foo bar = {
        description: ''
        argument (A)
        para (A) {
            description: '-'
            ordered, cmdline, splat, required, !interact
            no default
            flags []
            ge ()
            va (::cmdr::validate::identity)
            wd ()
        }
    }
................................................................................
        map --n --> (--no-A)
        map --no --> (--no-A)
        map --no- --> (--no-A)
        map --no-A --> (--no-A)
        map -A --> (-A)
        para (A) {
            description: '-'
            !ordered, cmdline, splat, !required, !interact
            default: ''
            flags [--no-A -A]
            ge ()
            va (::cmdr::validate::boolean)
            wd ()
        }
    }
................................................................................
test cmdr-parameter-5.4 {parameter DSL, list state} -body {
    NiceParamSpec state { list }
} -result {
    foo bar = {
        description: ''
        para (A) {
            description: '-'
            !ordered, !cmdline, splat, required, !interact
            default: ''
            flags []
            ge ()
            va (::cmdr::validate::identity)
            wd ()
        }
    }
................................................................................
    NiceParamSpec input { optional }
} -result {
    foo bar = {
        description: ''
        argument (A)
        para (A) {
            description: '-'
            ordered, cmdline, !splat, !required, !interact
            default: ''
            mode=threshold 0
            flags []
            ge ()
            va (::cmdr::validate::identity)
            wd ()
        }
................................................................................
    NiceParamSpec input { optional ; test }
} -result {
    foo bar = {
        description: ''
        argument (A)
        para (A) {
            description: '-'
            ordered, cmdline, !splat, !required, !interact
            default: ''
            mode=peek+test
            flags []
            ge ()
            va (::cmdr::validate::identity)
            wd ()
        }
................................................................................

# # ## ### ##### ######## ############# #####################
## Parameter DSL: 'validate' across parameters (input, option, state)

test cmdr-parameter-8.0 {parameter DSL, validate, wrong num args, not enough} -body {
    BadParamSpec input { validate }
} -returnCodes error \
    -result "wrong # args: should be \"validate cmd\""

test cmdr-parameter-8.1 {parameter DSL, validate, wrong num args, too many} -body {
    BadParamSpec input { validate X Y }
} -returnCodes error \
    -result "wrong # args: should be \"validate cmd\""

test cmdr-parameter-8.2 {parameter DSL, input, validate, shorthand} -body {
    NiceParamSpec input { validate integer }
} -result {
    foo bar = {
        description: ''
        argument (A)
        para (A) {
            description: '-'
            ordered, cmdline, !splat, required, !interact
            no default
            flags []
            ge ()
            va (::cmdr::validate::integer)
            wd ()
        }
    }
................................................................................
    NiceParamSpec input { validate ::cmdr::validate::identity }
} -result {
    foo bar = {
        description: ''
        argument (A)
        para (A) {
            description: '-'
            ordered, cmdline, !splat, required, !interact
            no default
            flags []
            ge ()
            va (::cmdr::validate::identity)
            wd ()
        }
    }
................................................................................
} -result {
    foo bar = {
        description: ''
        option (-A) = A
        map -A --> (-A)
        para (A) {
            description: '-'
            !ordered, cmdline, !splat, !required, !interact
            default: '0'
            flags [-A]
            ge ()
            va (::cmdr::validate::integer)
            wd ()
        }
    }
................................................................................
} -result {
    foo bar = {
        description: ''
        option (-A) = A
        map -A --> (-A)
        para (A) {
            description: '-'
            !ordered, cmdline, !splat, !required, !interact
            default: ''
            flags [-A]
            ge ()
            va (::cmdr::validate::identity)
            wd ()
        }
    }
................................................................................
test cmdr-parameter-8.6 {parameter DSL, state, validate, shorthand} -body {
    NiceParamSpec state { validate integer }
} -result {
    foo bar = {
        description: ''
        para (A) {
            description: '-'
            !ordered, !cmdline, !splat, required, !interact
            default: '0'
            flags []
            ge ()
            va (::cmdr::validate::integer)
            wd ()
        }
    }
................................................................................
test cmdr-parameter-8.7 {parameter DSL, state, validate} -body {
    NiceParamSpec state { validate ::cmdr::validate::identity }
} -result {
    foo bar = {
        description: ''
        para (A) {
            description: '-'
            !ordered, !cmdline, !splat, required, !interact
            default: ''
            flags []
            ge ()
            va (::cmdr::validate::identity)
            wd ()
        }
    }
................................................................................
    NiceParamSpec input { when-defined X }
} -result {
    foo bar = {
        description: ''
        argument (A)
        para (A) {
            description: '-'
            ordered, cmdline, !splat, required, !interact
            no default
            flags []
            ge ()
            va (::cmdr::validate::identity)
            wd (X)
        }
    }
................................................................................
        map --n --> (--no-A)
        map --no --> (--no-A)
        map --no- --> (--no-A)
        map --no-A --> (--no-A)
        map -A --> (-A)
        para (A) {
            description: '-'
            !ordered, cmdline, !splat, !required, !interact
            default: 'no'
            flags [--no-A -A]
            ge ()
            va (::cmdr::validate::boolean)
            wd (X)
        }
    }
................................................................................
test cmdr-parameter-9.4 {parameter DSL, state, when-defined} -body {
    NiceParamSpec state { when-defined X }
} -result {
    foo bar = {
        description: ''
        para (A) {
            description: '-'
            !ordered, !cmdline, !splat, required, !interact
            default: ''
            flags []
            ge ()
            va (::cmdr::validate::identity)
            wd (X)
        }
    }
}

# # ## ### ##### ######## ############# #####################
return






|







 







|







 







|







 







|







 







|







 







|







 







|







 







|







 







|







 







|







 







|







 







|







 







|







 







|







 







|

|







 







|







 







|

|







 







|

|







 







|







 







|







 







|







 







|







 







|







 







|




|









|







 







|







 







|







 







|







 







|







 







|







 







|







 







|







 







|











41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
..
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
...
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
...
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
...
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
...
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
...
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
...
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
...
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
...
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
...
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
...
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
...
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
...
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
...
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
...
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
...
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
...
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
...
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
...
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
...
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
...
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
...
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
...
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
...
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
...
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
...
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
...
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
...
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
...
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
...
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
...
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
        map --no --> (--no-A)
        map --no- --> (--no-A)
        map --no-A --> (--no-A)
        map -A --> (-A)
        map -X --> (-X)
        para (A) {
            description: '-'
            unordered, cmdline, single, optional, silent, immediate
            default: 'no'
            flags [--no-A -A -X]
            ge ()
            va (::cmdr::validate::boolean)
            wd ()
        }
    }
................................................................................
        map --no --> (--no-A)
        map --no- --> (--no-A)
        map --no-A --> (--no-A)
        map -A --> (-A)
        map -X --> (-X)
        para (no-A) {
            description: '-'
            unordered, cmdline, single, optional, silent, immediate
            default: 'no'
            flags [--no-A -A -X]
            ge ()
            va (::cmdr::validate::boolean)
            wd ()
        }
    }
................................................................................
    NiceParamSpec input { optional ; default 0 }
} -result {
    foo bar = {
        description: ''
        argument (A)
        para (A) {
            description: '-'
            ordered, cmdline, single, optional, silent, immediate
            default: '0'
            mode=threshold 0
            flags []
            ge ()
            va (::cmdr::validate::boolean)
            wd ()
        }
................................................................................
    NiceParamSpec input { optional ; default 2 }
} -result {
    foo bar = {
        description: ''
        argument (A)
        para (A) {
            description: '-'
            ordered, cmdline, single, optional, silent, immediate
            default: '2'
            mode=threshold 0
            flags []
            ge ()
            va (::cmdr::validate::integer)
            wd ()
        }
................................................................................
    NiceParamSpec input { optional ; default X }
} -result {
    foo bar = {
        description: ''
        argument (A)
        para (A) {
            description: '-'
            ordered, cmdline, single, optional, silent, immediate
            default: 'X'
            mode=threshold 0
            flags []
            ge ()
            va (::cmdr::validate::identity)
            wd ()
        }
................................................................................
        map --n --> (--no-A)
        map --no --> (--no-A)
        map --no- --> (--no-A)
        map --no-A --> (--no-A)
        map -A --> (-A)
        para (A) {
            description: '-'
            unordered, cmdline, single, optional, silent, immediate
            default: '0'
            flags [--no-A -A]
            ge ()
            va (::cmdr::validate::boolean)
            wd ()
        }
    }
................................................................................
} -result {
    foo bar = {
        description: ''
        option (-A) = A
        map -A --> (-A)
        para (A) {
            description: '-'
            unordered, cmdline, single, optional, silent, immediate
            default: '2'
            flags [-A]
            ge ()
            va (::cmdr::validate::integer)
            wd ()
        }
    }
................................................................................
} -result {
    foo bar = {
        description: ''
        option (-A) = A
        map -A --> (-A)
        para (A) {
            description: '-'
            unordered, cmdline, single, optional, silent, immediate
            default: 'X'
            flags [-A]
            ge ()
            va (::cmdr::validate::identity)
            wd ()
        }
    }
................................................................................
test cmdr-parameter-2.9 {parameter DSL, state, default, auto validate boolean} -body {
    NiceParamSpec state { default 0 }
} -result {
    foo bar = {
        description: ''
        para (A) {
            description: '-'
            unordered, hidden, single, required, silent, defered
            default: '0'
            flags []
            ge ()
            va (::cmdr::validate::boolean)
            wd ()
        }
    }
................................................................................
test cmdr-parameter-2.10 {parameter DSL, state, default, auto validate integer} -body {
    NiceParamSpec state { default 2 }
} -result {
    foo bar = {
        description: ''
        para (A) {
            description: '-'
            unordered, hidden, single, required, silent, defered
            default: '2'
            flags []
            ge ()
            va (::cmdr::validate::integer)
            wd ()
        }
    }
................................................................................
test cmdr-parameter-2.11 {parameter DSL, state, default, auto validate identity} -body {
    NiceParamSpec state { default X }
} -result {
    foo bar = {
        description: ''
        para (A) {
            description: '-'
            unordered, hidden, single, required, silent, defered
            default: 'X'
            flags []
            ge ()
            va (::cmdr::validate::identity)
            wd ()
        }
    }
................................................................................
    NiceParamSpec input { optional ; generate G }
} -result {
    foo bar = {
        description: ''
        argument (A)
        para (A) {
            description: '-'
            ordered, cmdline, single, optional, silent, immediate
            no default
            mode=threshold 0
            flags []
            ge (G)
            va (::cmdr::validate::identity)
            wd ()
        }
................................................................................
} -result {
    foo bar = {
        description: ''
        option (-A) = A
        map -A --> (-A)
        para (A) {
            description: '-'
            unordered, cmdline, single, optional, silent, immediate
            no default
            flags [-A]
            ge (G)
            va (::cmdr::validate::identity)
            wd ()
        }
    }
................................................................................
test cmdr-parameter-3.4 {parameter DSL, state, generate} -body {
    NiceParamSpec state { generate G }
} -result {
    foo bar = {
        description: ''
        para (A) {
            description: '-'
            unordered, hidden, single, required, silent, defered
            no default
            flags []
            ge (G)
            va (::cmdr::validate::identity)
            wd ()
        }
    }
................................................................................
    NiceParamSpec input { optional ; interact }
} -result {
    foo bar = {
        description: ''
        argument (A)
        para (A) {
            description: '-'
            ordered, cmdline, single, optional, interact, immediate
            default: ''
            prompt: 'Enter A: '
            mode=threshold 0
            flags []
            ge ()
            va (::cmdr::validate::identity)
            wd ()
        }
    }
................................................................................
    NiceParamSpec input { optional ; interact HERE }
} -result {
    foo bar = {
        description: ''
        argument (A)
        para (A) {
            description: '-'
            ordered, cmdline, single, optional, interact, immediate
            default: ''
            prompt: 'HERE'
            mode=threshold 0
            flags []
            ge ()
            va (::cmdr::validate::identity)
            wd ()
................................................................................
        map --n --> (--no-A)
        map --no --> (--no-A)
        map --no- --> (--no-A)
        map --no-A --> (--no-A)
        map -A --> (-A)
        para (A) {
            description: '-'
            unordered, cmdline, single, optional, interact, immediate
            default: 'no'
            prompt: 'Enter A: '
            flags [--no-A -A]
            ge ()
            va (::cmdr::validate::boolean)
            wd ()
        }
    }
}
................................................................................
test cmdr-parameter-4.5 {parameter DSL, state, interact} -body {
    NiceParamSpec state { interact }
} -result {
    foo bar = {
        description: ''
        para (A) {
            description: '-'
            unordered, hidden, single, required, interact, defered
            default: ''
            prompt: 'Enter A: '
            flags []
            ge ()
            va (::cmdr::validate::identity)
            wd ()
        }
    }
}
................................................................................
    NiceParamSpec input { list }
} -result {
    foo bar = {
        description: ''
        argument (A)
        para (A) {
            description: '-'
            ordered, cmdline, splat, required, silent, immediate
            no default
            flags []
            ge ()
            va (::cmdr::validate::identity)
            wd ()
        }
    }
................................................................................
        map --n --> (--no-A)
        map --no --> (--no-A)
        map --no- --> (--no-A)
        map --no-A --> (--no-A)
        map -A --> (-A)
        para (A) {
            description: '-'
            unordered, cmdline, splat, optional, silent, immediate
            default: ''
            flags [--no-A -A]
            ge ()
            va (::cmdr::validate::boolean)
            wd ()
        }
    }
................................................................................
test cmdr-parameter-5.4 {parameter DSL, list state} -body {
    NiceParamSpec state { list }
} -result {
    foo bar = {
        description: ''
        para (A) {
            description: '-'
            unordered, hidden, splat, required, silent, defered
            default: ''
            flags []
            ge ()
            va (::cmdr::validate::identity)
            wd ()
        }
    }
................................................................................
    NiceParamSpec input { optional }
} -result {
    foo bar = {
        description: ''
        argument (A)
        para (A) {
            description: '-'
            ordered, cmdline, single, optional, silent, immediate
            default: ''
            mode=threshold 0
            flags []
            ge ()
            va (::cmdr::validate::identity)
            wd ()
        }
................................................................................
    NiceParamSpec input { optional ; test }
} -result {
    foo bar = {
        description: ''
        argument (A)
        para (A) {
            description: '-'
            ordered, cmdline, single, optional, silent, immediate
            default: ''
            mode=peek+test
            flags []
            ge ()
            va (::cmdr::validate::identity)
            wd ()
        }
................................................................................

# # ## ### ##### ######## ############# #####################
## Parameter DSL: 'validate' across parameters (input, option, state)

test cmdr-parameter-8.0 {parameter DSL, validate, wrong num args, not enough} -body {
    BadParamSpec input { validate }
} -returnCodes error \
    -result "wrong # args: should be \"validate cmdprefix\""

test cmdr-parameter-8.1 {parameter DSL, validate, wrong num args, too many} -body {
    BadParamSpec input { validate X Y }
} -returnCodes error \
    -result "wrong # args: should be \"validate cmdprefix\""

test cmdr-parameter-8.2 {parameter DSL, input, validate, shorthand} -body {
    NiceParamSpec input { validate integer }
} -result {
    foo bar = {
        description: ''
        argument (A)
        para (A) {
            description: '-'
            ordered, cmdline, single, required, silent, immediate
            no default
            flags []
            ge ()
            va (::cmdr::validate::integer)
            wd ()
        }
    }
................................................................................
    NiceParamSpec input { validate ::cmdr::validate::identity }
} -result {
    foo bar = {
        description: ''
        argument (A)
        para (A) {
            description: '-'
            ordered, cmdline, single, required, silent, immediate
            no default
            flags []
            ge ()
            va (::cmdr::validate::identity)
            wd ()
        }
    }
................................................................................
} -result {
    foo bar = {
        description: ''
        option (-A) = A
        map -A --> (-A)
        para (A) {
            description: '-'
            unordered, cmdline, single, optional, silent, immediate
            default: '0'
            flags [-A]
            ge ()
            va (::cmdr::validate::integer)
            wd ()
        }
    }
................................................................................
} -result {
    foo bar = {
        description: ''
        option (-A) = A
        map -A --> (-A)
        para (A) {
            description: '-'
            unordered, cmdline, single, optional, silent, immediate
            default: ''
            flags [-A]
            ge ()
            va (::cmdr::validate::identity)
            wd ()
        }
    }
................................................................................
test cmdr-parameter-8.6 {parameter DSL, state, validate, shorthand} -body {
    NiceParamSpec state { validate integer }
} -result {
    foo bar = {
        description: ''
        para (A) {
            description: '-'
            unordered, hidden, single, required, silent, defered
            default: '0'
            flags []
            ge ()
            va (::cmdr::validate::integer)
            wd ()
        }
    }
................................................................................
test cmdr-parameter-8.7 {parameter DSL, state, validate} -body {
    NiceParamSpec state { validate ::cmdr::validate::identity }
} -result {
    foo bar = {
        description: ''
        para (A) {
            description: '-'
            unordered, hidden, single, required, silent, defered
            default: ''
            flags []
            ge ()
            va (::cmdr::validate::identity)
            wd ()
        }
    }
................................................................................
    NiceParamSpec input { when-defined X }
} -result {
    foo bar = {
        description: ''
        argument (A)
        para (A) {
            description: '-'
            ordered, cmdline, single, required, silent, immediate
            no default
            flags []
            ge ()
            va (::cmdr::validate::identity)
            wd (X)
        }
    }
................................................................................
        map --n --> (--no-A)
        map --no --> (--no-A)
        map --no- --> (--no-A)
        map --no-A --> (--no-A)
        map -A --> (-A)
        para (A) {
            description: '-'
            unordered, cmdline, single, optional, silent, immediate
            default: 'no'
            flags [--no-A -A]
            ge ()
            va (::cmdr::validate::boolean)
            wd (X)
        }
    }
................................................................................
test cmdr-parameter-9.4 {parameter DSL, state, when-defined} -body {
    NiceParamSpec state { when-defined X }
} -result {
    foo bar = {
        description: ''
        para (A) {
            description: '-'
            unordered, hidden, single, required, silent, defered
            default: ''
            flags []
            ge ()
            va (::cmdr::validate::identity)
            wd (X)
        }
    }
}

# # ## ### ##### ######## ############# #####################
return

Changes to tests/private.tests.

40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
..
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
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
...
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
...
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
...
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
        map --OP --> (--OPTION)
        map --OPT --> (--OPTION)
        map --OPTI --> (--OPTION)
        map --OPTIO --> (--OPTION)
        map --OPTION --> (--OPTION)
        para (INPUT) {
            description: 'INPUT-DESC'
            ordered, cmdline, !splat, required, !interact
            no default
            flags []
            ge ()
            va (::cmdr::validate::identity)
            wd ()
        }
        para (OPTION) {
            description: 'OPTION-DESC'
            !ordered, cmdline, !splat, !required, !interact
            default: 'no'
            flags [--no-OPTION --OPTION]
            ge ()
            va (::cmdr::validate::boolean)
            wd ()
        }
        para (STATE) {
            description: 'STATE-DESC'
            !ordered, !cmdline, !splat, required, !interact
            default: ''
            flags []
            ge ()
            va (::cmdr::validate::identity)
            wd ()
        }
    }
................................................................................
        argument (A)
        argument (B)
        argument (C)
        argument (D)
        argument (E)
        para (A) {
            description: '-'
            ordered, cmdline, !splat, required, !interact
            no default
            flags []
            ge ()
            va (::cmdr::validate::identity)
            wd ()
        }
        para (B) {
            description: '-'
            ordered, cmdline, !splat, !required, !interact
            default: ''
            mode=threshold 2
            flags []
            ge ()
            va (::cmdr::validate::identity)
            wd ()
        }
        para (C) {
            description: '-'
            ordered, cmdline, !splat, required, !interact
            no default
            flags []
            ge ()
            va (::cmdr::validate::identity)
            wd ()
        }
        para (D) {
            description: '-'
            ordered, cmdline, !splat, !required, !interact
            default: ''
            mode=threshold 1
            flags []
            ge ()
            va (::cmdr::validate::identity)
            wd ()
        }
        para (E) {
            description: '-'
            ordered, cmdline, !splat, required, !interact
            no default
            flags []
            ge ()
            va (::cmdr::validate::identity)
            wd ()
        }
    }
................................................................................
    x destroy
} -result {
    foo bar = {
        description: ''
        argument (A)
        para (A) {
            description: 'D'
            ordered, cmdline, !splat, required, !interact
            no default
            flags []
            ge ()
            va (::cmdr::validate::identity)
            wd ()
        }
    }
................................................................................
        map --n --> (--no-A)
        map --no --> (--no-A)
        map --no- --> (--no-A)
        map --no-A --> (--no-A)
        map -A --> (-A)
        para (A) {
            description: 'D'
            !ordered, cmdline, !splat, !required, !interact
            default: 'no'
            flags [--no-A -A]
            ge ()
            va (::cmdr::validate::boolean)
            wd ()
        }
    }
................................................................................
} -cleanup {
    x destroy
} -result {
    foo bar = {
        description: ''
        para (A) {
            description: 'D'
            !ordered, !cmdline, !splat, required, !interact
            default: ''
            flags []
            ge ()
            va (::cmdr::validate::identity)
            wd ()
        }
    }
}

# # ## ### ##### ######## ############# #####################
return






|








|








|







 







|








|









|








|









|







 







|







 







|







 







|











40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
..
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
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
...
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
...
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
...
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
        map --OP --> (--OPTION)
        map --OPT --> (--OPTION)
        map --OPTI --> (--OPTION)
        map --OPTIO --> (--OPTION)
        map --OPTION --> (--OPTION)
        para (INPUT) {
            description: 'INPUT-DESC'
            ordered, cmdline, single, required, silent, immediate
            no default
            flags []
            ge ()
            va (::cmdr::validate::identity)
            wd ()
        }
        para (OPTION) {
            description: 'OPTION-DESC'
            unordered, cmdline, single, optional, silent, immediate
            default: 'no'
            flags [--no-OPTION --OPTION]
            ge ()
            va (::cmdr::validate::boolean)
            wd ()
        }
        para (STATE) {
            description: 'STATE-DESC'
            unordered, hidden, single, required, silent, defered
            default: ''
            flags []
            ge ()
            va (::cmdr::validate::identity)
            wd ()
        }
    }
................................................................................
        argument (A)
        argument (B)
        argument (C)
        argument (D)
        argument (E)
        para (A) {
            description: '-'
            ordered, cmdline, single, required, silent, immediate
            no default
            flags []
            ge ()
            va (::cmdr::validate::identity)
            wd ()
        }
        para (B) {
            description: '-'
            ordered, cmdline, single, optional, silent, immediate
            default: ''
            mode=threshold 2
            flags []
            ge ()
            va (::cmdr::validate::identity)
            wd ()
        }
        para (C) {
            description: '-'
            ordered, cmdline, single, required, silent, immediate
            no default
            flags []
            ge ()
            va (::cmdr::validate::identity)
            wd ()
        }
        para (D) {
            description: '-'
            ordered, cmdline, single, optional, silent, immediate
            default: ''
            mode=threshold 1
            flags []
            ge ()
            va (::cmdr::validate::identity)
            wd ()
        }
        para (E) {
            description: '-'
            ordered, cmdline, single, required, silent, immediate
            no default
            flags []
            ge ()
            va (::cmdr::validate::identity)
            wd ()
        }
    }
................................................................................
    x destroy
} -result {
    foo bar = {
        description: ''
        argument (A)
        para (A) {
            description: 'D'
            ordered, cmdline, single, required, silent, immediate
            no default
            flags []
            ge ()
            va (::cmdr::validate::identity)
            wd ()
        }
    }
................................................................................
        map --n --> (--no-A)
        map --no --> (--no-A)
        map --no- --> (--no-A)
        map --no-A --> (--no-A)
        map -A --> (-A)
        para (A) {
            description: 'D'
            unordered, cmdline, single, optional, silent, immediate
            default: 'no'
            flags [--no-A -A]
            ge ()
            va (::cmdr::validate::boolean)
            wd ()
        }
    }
................................................................................
} -cleanup {
    x destroy
} -result {
    foo bar = {
        description: ''
        para (A) {
            description: 'D'
            unordered, hidden, single, required, silent, defered
            default: ''
            flags []
            ge ()
            va (::cmdr::validate::identity)
            wd ()
        }
    }
}

# # ## ### ##### ######## ############# #####################
return

Changes to tests/runtime.tests.

382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
}

test cmdr-runtime-3.5 {options, list, string, missing value} -body {
    Parse {
	option A - { list ; validate identity }
    } -A
} -returnCodes error \
    -result "wrong\#args, not enough"

test cmdr-runtime-3.6 {options, list, string} -body {
    Parse {
	option A - { list ; validate identity }
    } -A X
} -result {
    A = 'X' v'X'






|







382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
}

test cmdr-runtime-3.5 {options, list, string, missing value} -body {
    Parse {
	option A - { list ; validate identity }
    } -A
} -returnCodes error \
    -result "wrong\#args, missing value for option '-A'"

test cmdr-runtime-3.6 {options, list, string} -body {
    Parse {
	option A - { list ; validate identity }
    } -A X
} -result {
    A = 'X' v'X'

Changes to tests/support.tcl.

222
223
224
225
226
227
228
229
230
231
232
233

234
235
236
237
238
239
240
    foreach name [lsort -dict [$o names]] {
	set c [$o lookup $name]

	lappend result "    para ($name) \{"
	lappend result "        description: '[$c description]'"

	set state {}
	if {[$c ordered]}     { lappend state ordered  } else { lappend state !ordered  }
	if {[$c cmdline]}     { lappend state cmdline  } else { lappend state !cmdline  }
	if {[$c list]}        { lappend state splat    } else { lappend state !splat    }
	if {[$c required]}    { lappend state required } else { lappend state !required }
	if {[$c interactive]} { lappend state interact } else { lappend state !interact }

	lappend result "        [join $state {, }]"

	if {[$c hasdefault]}  {
	    lappend result "        default: '[$c default]'"
	} else {
	    lappend result "        no default"
	}






|
|
|
|
|
>







222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
    foreach name [lsort -dict [$o names]] {
	set c [$o lookup $name]

	lappend result "    para ($name) \{"
	lappend result "        description: '[$c description]'"

	set state {}
	if {[$c ordered]}     { lappend state ordered  } else { lappend state unordered }
	if {[$c cmdline]}     { lappend state cmdline  } else { lappend state hidden    }
	if {[$c list]}        { lappend state splat    } else { lappend state single    }
	if {[$c required]}    { lappend state required } else { lappend state optional  }
	if {[$c interactive]} { lappend state interact } else { lappend state silent    }
	if {[$c defered]}     { lappend state defered  } else { lappend state immediate }
	lappend result "        [join $state {, }]"

	if {[$c hasdefault]}  {
	    lappend result "        default: '[$c default]'"
	} else {
	    lappend result "        no default"
	}

Changes to util.tcl.

59
60
61
62
63
64
65
66
    set res {}
    foreach str $list { lappend res [format "%-*s" $maxl $str] }
    return $res
}

# # ## ### ##### ######## ############# #####################
## Ready
package provide cmdr::util 0.2






|
59
60
61
62
63
64
65
66
    set res {}
    foreach str $list { lappend res [format "%-*s" $maxl $str] }
    return $res
}

# # ## ### ##### ######## ############# #####################
## Ready
package provide cmdr::util 0.3

Changes to validate.tcl.

313
314
315
316
317
318
319
320
321
    if {![file readable    $path]} {return 0}
    if {![file writable    $path]} {return 0}
    return 1
}

# # ## ### ##### ######## ############# #####################
## Ready
package provide cmdr::validate 0.2
return






|

313
314
315
316
317
318
319
320
321
    if {![file readable    $path]} {return 0}
    if {![file writable    $path]} {return 0}
    return 1
}

# # ## ### ##### ######## ############# #####################
## Ready
package provide cmdr::validate 0.3
return

Changes to vcommon.tcl.

94
95
96
97
98
99
100
101
102
    debug.cmdr/validate/common {= [join $candidates "\n= "]} 10
    return $candidates
}

# # ## ### ##### ######## ############# #####################
## Ready
package provide cmdr::validate::common 0.2
return






|

94
95
96
97
98
99
100
101
102
    debug.cmdr/validate/common {= [join $candidates "\n= "]} 10
    return $candidates
}

# # ## ### ##### ######## ############# #####################
## Ready
package provide cmdr::validate::common 0.3
return