Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Changes In Branch neg-aliases Excluding Merge-Ins
This is equivalent to a diff from 868958ed6d to 21b94c7e50
2015-05-12
| ||
22:03 | Merged work on negative aliases. check-in: 88c1cb79e5 user: aku tags: trunk | |
22:02 | Added docs for negative aliases. Closed-Leaf check-in: 21b94c7e50 user: aku tags: neg-aliases | |
21:53 | Added tests checking runtime handling of negative aliases. check-in: af44ad2581 user: aku tags: neg-aliases | |
2015-05-11
| ||
22:28 | Merged trunk testsuite fixes. check-in: 5ae1694710 user: aku tags: neg-aliases | |
22:28 | Merged trunk testsuite fixes. check-in: 133579f38a user: aku tags: vtype-testing | |
22:27 | Really complete fixes for help testsuite. check-in: 868958ed6d user: aku tags: trunk | |
2015-05-09
| ||
00:06 | Comment fixes check-in: ebdf8cc004 user: andreask tags: trunk | |
Changes to config.tcl.
︙ | |||
1083 1084 1085 1086 1087 1088 1089 | 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 | - + + | CMDR CONFIG AMBIGUOUS OPTION } # Now map the fully expanded option name to its handler and # let it deal with the remaining things, including retrieval # of the option argument (if any), validation, etc. |
︙ |
Changes to doc/parts/dsl_para_naming.inc.
︙ | |||
43 44 45 46 47 48 49 50 51 52 53 54 | 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 | + + + + + + + + + + + + + + | If that is not enough for a specific [term option] this command allows the specification of any number additional flags to be recognized. [para] Note however that the framework automatically recognizes not only the specified flag(s), but also all their unique prefixes, obviating the need for this command in many cases. [comment {- - -- --- ----- -------- -------------}] [call [cmd neg-alias] [arg name]] [call [cmd !alias] [arg name]] This command applies only to [term boolean] [term option]s. For them it allows the specification of any number additional flags to be recognized, which are aliases of its [emph inverted] form, i.e. of [const --no-FOO] for an option [const FOO]. [para] This in contrast to [cmd alias]es, which are for the regular form of the option. [para] Note further that the framework automatically recognizes not only the specified flag(s), but also all their unique prefixes, obviating the need for this command in many cases. [list_end] |
Changes to embedded/man/files/cmdr_dsl_parameter.n.
︙ | |||
275 276 277 278 279 280 281 282 283 284 285 286 287 288 | 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 | + + + + | .SH NAME cmdr-spec-dsl-parameter \- Cmdr - Parameter Specification Language .SH SYNOPSIS \fBlabel\fR \fItext\fR .sp \fBalias\fR \fIname\fR .sp \fBneg-alias\fR \fIname\fR .sp \fB!alias\fR \fIname\fR .sp \fBno-promotion\fR .sp \fBoptional\fR .sp \fBtest\fR .sp \fBundocumented\fR |
︙ | |||
387 388 389 390 391 392 393 394 395 396 397 398 399 400 | 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 | + + + + + + + + + + + + + | \fIParsing\fR phase\&. If that is not enough for a specific \fIoption\fR this command allows the specification of any number additional flags to be recognized\&. .sp Note however that the framework automatically recognizes not only the specified flag(s), but also all their unique prefixes, obviating the need for this command in many cases\&. .TP \fBneg-alias\fR \fIname\fR .TP \fB!alias\fR \fIname\fR This command applies only to \fIboolean\fR \fIoption\fRs\&. For them it allows the specification of any number additional flags to be recognized, which are aliases of its \fIinverted\fR form, i\&.e\&. of \fB--no-FOO\fR for an option \fBFOO\fR\&. .sp This in contrast to \fBalias\fRes, which are for the regular form of the option\&. .sp Note further that the framework automatically recognizes not only the specified flag(s), but also all their unique prefixes, obviating the need for this command in many cases\&. .PP .PP .SS "GENERAL CONTROL" .PP The general handling of a \fIparameter\fR is influenced by three commands: .TP |
︙ |
Changes to embedded/www/doc/files/cmdr_dsl_parameter.html.
︙ | |||
131 132 133 134 135 136 137 | 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 | - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + | </ul> </div> <div id="synopsis" class="section"><h2><a name="synopsis">Synopsis</a></h2> <div class="synopsis"> <ul class="syntax"> <li><a href="#1"><b class="cmd">label</b> <i class="arg">text</i></a></li> <li><a href="#2"><b class="cmd">alias</b> <i class="arg">name</i></a></li> |
︙ | |||
215 216 217 218 219 220 221 222 223 224 225 226 227 | 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 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 | + + + + + + + + + + - + - + - + - + | the name of the <i class="term">primary flag</i> recognized during the <i class="term">Parsing</i> phase. If that is not enough for a specific <i class="term">option</i> this command allows the specification of any number additional flags to be recognized.</p> <p>Note however that the framework automatically recognizes not only the specified flag(s), but also all their unique prefixes, obviating the need for this command in many cases.</p></dd> <dt><a name="3"><b class="cmd">neg-alias</b> <i class="arg">name</i></a></dt> <dd></dd> <dt><a name="4"><b class="cmd">!alias</b> <i class="arg">name</i></a></dt> <dd><p>This command applies only to <i class="term">boolean</i> <i class="term">option</i>s. For them it allows the specification of any number additional flags to be recognized, which are aliases of its <em>inverted</em> form, i.e. of <b class="const">--no-FOO</b> for an option <b class="const">FOO</b>.</p> <p>This in contrast to <b class="cmd">alias</b>es, which are for the regular form of the option.</p> <p>Note further that the framework automatically recognizes not only the specified flag(s), but also all their unique prefixes, obviating the need for this command in many cases.</p></dd> </dl> </div> <div id="subsection2" class="subsection"><h3><a name="subsection2">General control</a></h3> <p>The general handling of a <i class="term">parameter</i> is influenced by three commands:</p> <dl class="definitions"> |
︙ | |||
272 273 274 275 276 277 278 | 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 | - + - + - + | The details of that process are explained in section <span class="sectref"><a href="#subsection4">Validation</a></span>. However we have cases where the user cannot specify a string representation (<i class="term">state</i>s), or is allowed to choose not to (optional <i class="term">input</i>s, <i class="term">option</i>s). For these cases three specification commands are made available enabling us to programmatically choose the internal representation.</p> <dl class="definitions"> |
︙ | |||
324 325 326 327 328 329 330 | 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 | - + | <li><p>After that the <i class="term">internal representation</i> is either the declared <b class="cmd">default</b> value, or the result of invoking the <b class="cmd">generate</b> callback. As <i class="term">internal representation</i>s the resulting values are <em>not</em> run through the chosen <i class="term">validation type</i>.</p></li> </ol> <dl class="definitions"> |
︙ | |||
347 348 349 350 351 352 353 | 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 | - + - + | this list-<i class="term">inputs</i> are only allowed as the last <i class="term">parameter</i> of a <i class="term">private</i>.</p></dd> </dl> <p>The last two specification commands dealing with the representations control <em>when</em> the <i class="term">internal representation</i> is created.</p> <dl class="definitions"> |
︙ | |||
376 377 378 379 380 381 382 | 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 | - + - + | Cmdr expects all types to support an ensemble of <em>four</em> methods. One for the basic validation and transformation of the input, another for the release of any internal representation so generated, plus two more for delivery of a default representation and support for command line completion.</p> <dl class="definitions"> |
︙ | |||
442 443 444 445 446 447 448 | 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 | - + - + | system, as complex scripts can be used via procedures or equivalents (i.e. <b class="cmd">apply</b>).</p> <p>The two callbacks not yet described are the state-change callbacks through which the framework can actively drive parts of the application while processing the command line, whereas normally the application drives access to parameters through their methods.</p> <dl class="definitions"> |
︙ |
Changes to parameter.tcl.
︙ | |||
82 83 84 85 86 87 88 89 90 91 92 93 94 95 | 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | + | my C2_OptionIsOptional my C3_StateIsRequired set mystopinteraction no ;# specified interaction is not suppressed. set myislist no ;# scalar vs list parameter set myisdocumented yes set myonlypresence no ;# options only, no argument when true. set myhasinverted no ;# options only, presence of negative aliases. set myhasdefault no ;# flag for default existence set mydefault {} ;# default value - raw set mygenerate {} ;# generator command prefix set myinteractive no ;# no interactive query of value set myprompt "Enter ${name}: " ;# standard prompt for interaction set myvalidate {} ;# validation command prefix |
︙ | |||
173 174 175 176 177 178 179 180 181 182 183 184 185 186 | 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 | + + + + | primary {} alias { return "Alias of [my Option $myname]." } inverted { return "Complementary alias of [my Option $myname]." } } } return $mydescription } method flag-type {detail} { return [dict get $myflags $detail] } method primary {option} { return [expr {[dict get $myflags $option] eq "primary"}] } method flag {} { my Option $mylabel |
︙ | |||
274 275 276 277 278 279 280 281 282 283 284 285 286 287 | 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 | + + | # generated text as description of the aliases. set myflags {} # Import the DSL commands to translate the specification. link \ {alias Alias} \ {!alias NegAlias} \ {neg-alias NegAlias} \ {default Default} \ {defered Defered} \ {generate Generate} \ {immediate Immediate} \ {interact Interact} \ {label Label} \ {argument ArgLabel} \ |
︙ | |||
313 314 315 316 317 318 319 320 321 322 323 324 325 326 | 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 | + + | my C3_StateIsRequired my C5_OptionalHasAlternateInput my C5_StateHasAlternateInput my C6_RequiredArgumentForbiddenDefault my C6_RequiredArgumentForbiddenGenerator my C6_RequiredArgumentForbiddenInteract my C7_DefaultGeneratorConflict my C10_ForbiddenInvertedAlias my C11_ForbiddenInvertedAlias return } # # ## ### ##### ######## ############# ## Utility functionality for easy setup of exclusions and data ## propagation |
︙ | |||
378 379 380 381 382 383 384 385 386 387 388 389 390 391 | 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 | + + + + + + + | } method Alias {name} { my Alias_Option dict set myflags [my Option $name] alias return } method NegAlias {name} { my Alias_Option dict set myflags [my Option $name] inverted set myhasinverted yes return } method Optional {} { # Arguments only. Options are already optional, and state # parameters must not be. my Optional_State ; # Order of tests is important, enabling us my Optional_Option ; # to simplify the guard conditions inside. set myisrequired no |
︙ | |||
530 531 532 533 534 535 536 | 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 | - + - + - + - + + + + + + + + + + + + + + + | forward C8_PresenceOption \ my Assert {$myiscmdline && !$myisordered} \ {Non-option parameter "@" cannot have presence-only} forward C9_ForbiddenPresence \ my Assert {(!$myhasdefault && ![llength $mygenerate] && ![llength $myvalidate]) || !$myonlypresence} \ |
︙ | |||
669 670 671 672 673 674 675 676 677 678 679 680 681 682 | 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 | + | set alternate [string range $myname 3 end] } else { # The primary option is not inverted, make an alias which is. set alternate no-$myname } dict set myflags [my Option $alternate] inverted set myhasinverted yes return } method Option {name} { # Short options (single character) get a single-dash '-'. # Long options use a double-dash '--'. if {[string length $name] == 1} { |
︙ | |||
859 860 861 862 863 864 865 | 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 | - + - + | # Look for and process boolean special forms. # Insert implied boolean flag value. # # --foo non-boolean-value ==> --foo YES non-boolean-value # --no-foo non-boolean-value ==> --foo NO non-boolean-value |
︙ | |||
1257 1258 1259 1260 1261 1262 1263 | 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 | - + | 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 \ |
Changes to tests/parameter.tests.
︙ | |||
44 45 46 47 48 49 50 51 52 53 54 55 56 57 | 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | + + + | map -A --> (-A) map -X --> (-X) para (A) { description: '-' unordered, cmdline, single, optional, silent, immediate default: 'no' flags [--no-A -A -X] --no-A = inverted -A = primary -X = alias ge () va (::cmdr::validate::boolean) wd () } } } |
︙ | |||
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | 78 79 80 81 82 83 84 85 86 87 88 89 90 91 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 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | map -A --> (-A) map -X --> (-X) para (no-A) { description: '-' unordered, cmdline, single, optional, silent, immediate default: 'no' flags [--no-A -A -X] --no-A = primary -A = inverted -X = alias ge () va (::cmdr::validate::boolean) wd () } } } test cmdr-parameter-1.6 {parameter DSL, option, negative alias} -body { NiceParamSpec option { neg-alias X } } -result { foo bar = { description: '' option (--no-A) = A option (-A) = A option (-X) = A map --n --> (--no-A) 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] --no-A = inverted -A = primary -X = inverted ge () va (::cmdr::validate::boolean) wd () } } } test cmdr-parameter-1.7 {parameter DSL, option, non-boolean, negative alias} -body { BadParamSpec option { default 2 ; neg-alias X } } -returnCodes error \ -result {Non-boolean option "A" cannot have negated alias} test cmdr-parameter-1.8 {parameter DSL, option, presence, negative alias} -body { BadParamSpec option { presence ; neg-alias X } } -returnCodes error \ -result {Presence option "A" cannot have negated alias} # # ## ### ##### ######## ############# ##################### ## Parameter DSL: 'default' across parameters (input, option, state) test cmdr-parameter-2.0 {parameter DSL, default, wrong num args, not enough} -body { BadParamSpec input { default } } -returnCodes error \ |
︙ | |||
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 | 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 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 | + + + + | map --no-A --> (--no-A) map -A --> (-A) para (A) { description: '-' unordered, cmdline, single, optional, silent, immediate default: '0' flags [--no-A -A] --no-A = inverted -A = primary ge () va (::cmdr::validate::boolean) wd () } } } test cmdr-parameter-2.7 {parameter DSL, option, default, auto validate integer } -body { NiceParamSpec option { default 2 } } -result { foo bar = { description: '' option (-A) = A map -A --> (-A) para (A) { description: '-' unordered, cmdline, single, optional, silent, immediate default: '2' flags [-A] -A = primary ge () va (::cmdr::validate::integer) wd () } } } test cmdr-parameter-2.8 {parameter DSL, option, default, auto validate identity} -body { NiceParamSpec option { default X } } -result { foo bar = { description: '' option (-A) = A map -A --> (-A) para (A) { description: '-' unordered, cmdline, single, optional, silent, immediate default: 'X' flags [-A] -A = primary ge () va (::cmdr::validate::identity) wd () } } } |
︙ | |||
334 335 336 337 338 339 340 341 342 343 344 345 346 347 | 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 | + | option (-A) = A map -A --> (-A) para (A) { description: '-' unordered, cmdline, single, optional, silent, immediate no default flags [-A] -A = primary ge (G) va (::cmdr::validate::identity) wd () } } } |
︙ | |||
444 445 446 447 448 449 450 451 452 453 454 455 456 457 | 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 | + + | map -A --> (-A) para (A) { description: '-' unordered, cmdline, single, optional, interact, immediate default: 'no' prompt: 'Enter A: ' flags [--no-A -A] --no-A = inverted -A = primary ge () va (::cmdr::validate::boolean) wd () } } } |
︙ | |||
526 527 528 529 530 531 532 533 534 535 536 537 538 539 | 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 | + + | map --no-A --> (--no-A) map -A --> (-A) para (A) { description: '-' unordered, cmdline, splat, optional, silent, immediate default: '' flags [--no-A -A] --no-A = inverted -A = primary ge () va (::cmdr::validate::boolean) wd () } } } |
︙ | |||
690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 | 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 | + + | option (-A) = A map -A --> (-A) para (A) { description: '-' unordered, cmdline, single, optional, silent, immediate default: '0' flags [-A] -A = primary ge () va (::cmdr::validate::integer) wd () } } } test cmdr-parameter-8.5 {parameter DSL, option, validate} -body { NiceParamSpec option { validate ::cmdr::validate::identity } } -result { foo bar = { description: '' option (-A) = A map -A --> (-A) para (A) { description: '-' unordered, cmdline, single, optional, silent, immediate default: '' flags [-A] -A = primary ge () va (::cmdr::validate::identity) wd () } } } |
︙ | |||
798 799 800 801 802 803 804 805 806 807 808 809 810 811 | 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 | + + | map --no-A --> (--no-A) map -A --> (-A) para (A) { description: '-' unordered, cmdline, single, optional, silent, immediate default: 'no' flags [--no-A -A] --no-A = inverted -A = primary ge () va (::cmdr::validate::boolean) wd (X) } } } |
︙ |
Changes to tests/private.tests.
︙ | |||
52 53 54 55 56 57 58 59 60 61 62 63 64 65 | 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | + + | wd () } para (OPTION) { description: 'OPTION-DESC' unordered, cmdline, single, optional, silent, immediate default: 'no' flags [--no-OPTION --OPTION] --no-OPTION = inverted --OPTION = primary ge () va (::cmdr::validate::boolean) wd () } para (STATE) { description: 'STATE-DESC' unordered, hidden, single, required, silent, defered |
︙ | |||
236 237 238 239 240 241 242 243 244 245 246 247 248 249 | 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 | + + | map --no-A --> (--no-A) map -A --> (-A) para (A) { description: 'D' unordered, cmdline, single, optional, silent, immediate default: 'no' flags [--no-A -A] --no-A = inverted -A = primary ge () va (::cmdr::validate::boolean) wd () } } } |
︙ |
Changes to tests/runtime.tests.
︙ | |||
618 619 620 621 622 623 624 625 626 627 628 | 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 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 665 666 667 668 669 670 671 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | test cmdr-runtime-7.2 {validation errors} -body { ParseFailParse { input A - { validate integer } input B - { validate integer } } 1 X } -returnCodes error \ -result {Expected an integer for input "B", got "X"} # # ## ### ##### ######## ############# ##################### ## Options, negative aliases test cmdr-runtime-8.0 {options, simple, boolean, special forms II} -body { Parse { option A - option B - option C - option D - option E - option F - option G - { validate identity } } -A -G=X --no-B -G=X -C=1 -D=0 --no-E=1 --no-F=0 } -result { A = 'yes' v'1' B = '0' v'0' C = '1' v'1' D = '0' v'0' E = '0' v'0' F = '1' v'1' G = 'X' v'X' } test cmdr-runtime-8.1 {options, boolean, aliases} -body { Parse { option A - { alias X } option B - { neg-alias Y } } -X -Y } -result { A = 'yes' v'1' B = '0' v'0' } test cmdr-runtime-8.2 {options, boolean, aliases, special forms} -body { Parse { option A - { alias X } option B - { neg-alias Y } } -X=0 -Y=0 } -result { A = '0' v'0' B = '1' v'1' } # # ## ### ##### ######## ############# ##################### return |
Changes to tests/support.tcl.
︙ | |||
248 249 250 251 252 253 254 255 256 257 258 259 260 261 | 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 | + + + | if {[$c threshold] >= 0} { lappend result " mode=threshold [$c threshold]" } else { lappend result " mode=peek+test" } } lappend result " flags \[[$c options]\]" foreach oname [$c options] { lappend result " $oname = [$c flag-type $oname]" } lappend result " ge ([$c generator])" lappend result " va ([$c validator])" lappend result " wd ([$c when-complete])" lappend result " \}" } lappend result "\}" |
︙ |