cmdr
Check-in [2bb154df7f]
Not logged in
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to tclconference@googlegroups.com
or submit via the online form by Sep 9.

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

Overview
Comment:Filled out docs for cmdr::config
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:2bb154df7f08dd71f9d054c702fc0d92cda0ef66
User & Date: andreask 2013-11-04 22:44:57
Context
2013-11-04
22:45
Added placeholders for missing reference docs check-in: 89659bfd6c user: andreask tags: trunk
22:44
Filled out docs for cmdr::config check-in: 2bb154df7f user: andreask tags: trunk
17:38
Reworked the interaction for entry of scalar, and general calculation of the value - Show validation error message for proper feedback - Trap ^C properly, as done for the list-case already. Scalar was forgotten. - Report the ^C as 'undefined value' - Remember the undefined-ness and have additional attempts to retrieve the value abort early This prevents retries of computing the value where we cannot succeed. It also prevents additional attempts at interaction. Bumped version to 0.10. check-in: d2a2bc511f user: andreask tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Added doc/cmdr_config.man.

































































































































































































































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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
73
74
75
76
77
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
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
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
275
276
277
278
279
280
281
282
283
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
322
323
324
325
326
327
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
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
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
424
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
461
462
463
464
[comment {-*- tcl -*- doctools manpage}]
[include parts/definitions.inc]
[manpage_begin [vset PROJECT]_config [vset MAN_SECTION] [vset VERSION]]
[include parts/module.inc]
[require cmdr::util]
[titledesc [vset TITLE_CONFIG]]
[description]
[include parts/welcome.inc]

This package implements the collections of [package cmdr::parameters]
serving as the configuration of privates (see [package cmdr::private]).

[comment @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@]
[section {Class API}]

The class API is not public. It is used internally by the framework
when parsing a command hierarchy specification to create the necessary
configuration instances.

[para] It is described here for use by developers maintaining,
modifying and extending the framework itself. A user of the framework
has no need for it.

[list_begin definitions]
[comment {- - -- --- ----- -------- -------------}]
[call [cmd ::cmdr::config] [method new] [arg context] [arg spec]]

Create an auto-named instance of [class cmdr::config].
[para] [emph {Not used}].

[comment {- - -- --- ----- -------- -------------}]
[call [cmd ::cmdr::config] [method create] [arg obj] [arg context] [arg spec]]

Create a new instance of [class cmdr::config], named [arg obj].


[list_begin arguments]

[arg_def string obj]
The (command) name of the new config instance.

[arg_def cmdr::config context]
The instance command of the [package cmdr::private] instance the configuration
will belong to.

[arg_def script spec]

Tcl-script specifying the parameters in detail. Please read
[term [vset TITLE_DSL]], section --TODO-- for the details.

[list_end][comment arguments]

[comment {- - -- --- ----- -------- -------------}]
[call [cmd ::cmdr::config] [method interactive] [opt [arg enable]]]

Class method to change the global interaction default for the
mini-shell of privates. The default is to disable this mini-shell
for all privates, and enable it on a per-private basis, through
the specification.

[list_begin arguments]
[arg_def boolean enable]
Defaults to [const true], globally activating the mini-shell.

[list_end][comment {--- arguments --}]

[comment {- - -- --- ----- -------- -------------}]
[call [cmd ::cmdr::config] [method display] [arg displaycmd]]

Class method to override the standard display command used by
the mini-shell to show the current state of all parameters.

[list_begin arguments]
[arg_def {commandprefix} displaycmd]

The display command to use. The command will be called with a
single argument, a list containing the names of the parameters
to show. The command has to format the state of the requested
parameters as a string and return this string as its result.

[list_end][comment {--- arguments --}]
[list_end][comment definitions]

[comment @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@]
[section {Instance API}]

Most of the instance API is not public.

[para] It is described here for use by developers maintaining,
modifying and extending the framework itself. A user of the framework
has no need for it.

[list_begin definitions]
[comment {- - -- --- ----- -------- -------------}]
[call [cmd <config>] [method @...] [arg ...]]

All parameters held by a configuration instance are accessible
through it. To this end each parameter named [var foo] has a
dynamically created accessor method [method @foo] taking the
method and its arguments to apply to the parameter instance.

[para] If no words are specified at all the system defaults to the
application of instance method [method value].

[para] Together with a parameter's ability to access the
configuration holding it having access to a single parameter
instance (like in the various callbacks) provides access to all.

[list_begin arguments]
[arg_def list list]
[list_end][comment {--- arguments --}]

[comment {- - -- --- ----- -------- -------------}]
[call [cmd <config>] [method arguments]]

This method returns a list of parameter names,
for the parameters which are arguments.

[comment {- - -- --- ----- -------- -------------}]
[call [cmd <config>] [method complete] [arg line]]

This hook-method for the mini-shell is responsible
for computing the set of completions for the
entered [arg line].

[list_begin arguments]
[arg_def string line]
The command line to complete.
[list_end][comment {--- arguments --}]

[comment {- - -- --- ----- -------- -------------}]
[call [cmd <config>] [method complete-repl] [arg parse]]

This internal method is used by the hook-method [method complete]
for the mini-shell, see above. It is given the completion
state [arg parse] of a partial command line and returns a
list of strings which are the valid completions at this point.

[list_begin arguments]
[arg_def dict parse]
A dictionary holding the current completion state of a partial command
line.

[para] -- TODO -- Describe the state fields and their meaning.
[list_end][comment {--- arguments --}]

[comment {- - -- --- ----- -------- -------------}]
[call [cmd <config>] [method complete-words] [arg parse]]

This method is given the completion state [arg parse] of a partial
command line and returns a list of strings which are the valid
completions at this point.

[list_begin arguments]
[arg_def dict parse]
A dictionary holding the current completion state of a partial command
line.

[para] -- TODO -- Describe the state fields and their meaning.
[list_end][comment {--- arguments --}]

[comment {- - -- --- ----- -------- -------------}]
[call [cmd <config>] [method continued] [arg line]]

This hook-method for the mini-shell is responsible for the detection
of a continuation-line in the entered command [arg line]. It always
returns the boolean value [const false] as the mini-shell does not
support continuation lines.

[list_begin arguments]
[arg_def list list]
[list_end][comment {--- arguments --}]

[comment {- - -- --- ----- -------- -------------}]
[call [cmd <config>] [method dispatch] [arg cmd]]

This hook-method for the mini-shell is responsible for
the recognition and execution of the supported commands.

[list_begin arguments]
[arg_def string cmd]
The command line containing the command to run.
[list_end][comment {--- arguments --}]

[comment {- - -- --- ----- -------- -------------}]
[call [cmd <config>] [method display] [opt [arg plist]]]

This method formats the chosen parameters for display and returns
the result as a string. This invokes the chosen display callback,
if one was set. Without an internal formatter is used instead.

[list_begin arguments]
[arg_def list plist]
The list of parameters (by name) to format for display.

If not specified the list default to the set of
[method public] parameters plus any undocumented parameters
already set by the user.
[list_end][comment {--- arguments --}]

[comment {- - -- --- ----- -------- -------------}]
[call [cmd <config>] [method dump]]

This method formats all parameters for display, using the
internal formatter, and returns the result as a string.

Useful for debugging.

[comment {- - -- --- ----- -------- -------------}]
[call [cmd <config>] [method eoptions]]

This method returns a dictionary mapping all possible
option prefixes to a list of full option names with
that prefix.

[comment {- - -- --- ----- -------- -------------}]
[call [cmd <config>] [method exit]]

This hook-method for the mini-shell returns a boolean
value indicating whether the mini-shell was stopped
and has to exit ([const true]), or not ([const false]).

[comment {- - -- --- ----- -------- -------------}]
[call [cmd <config>] [method force] [opt [arg allowinteract]] [opt [arg forcedefered]]]

This method forces the calculation of the values for all parameters
in the configuration instance. This is the ''completion phase''.

[list_begin arguments]
[arg_def boolean allowinteract]
If specified as [const false] parameters allowing the interactive
entry of their value have this feature disabled for the operation.
The default is [const true], allowing for the interaction.

[arg_def boolean forcedefered]
If specified as [const true] even parameters marked as "defered"
are forced to generate their value. The default is [const false],
causing the method to ignore such parameters.

[list_end][comment {--- arguments --}]

[comment {- - -- --- ----- -------- -------------}]
[call [cmd <config>] [method forget]]

This method invokes the parameter method [method forget] on all
parameters in the configuration.

[comment {- - -- --- ----- -------- -------------}]
[call [cmd <config>] [method has] [arg name]]

This method checks if the configuration instance contains
a parameter with the specified [arg name] and returns a
boolean value indicating whether the parameter exists
([const true]), or not ([const false]).

[list_begin arguments]
[arg_def string name]
The name of the parameter to check for existence
[list_end][comment {--- arguments --}]

[comment {- - -- --- ----- -------- -------------}]
[call [cmd <config>] [method help] [opt [arg mode]]]

This method returns the help information for the
parameters held in the configuration. 

The result of the command is a structure of the form
described in section [sectref {Help Information}].

[list_begin arguments]
[arg_def enum mode]
The possible modes are [const public] and [const interact].
If not specified [const public] is the default.
In this mode only "documented" parameters are included in the help.
In mode "interact", used by the mini-shell undocumented parameters
are included as well, if they are already set by the user.

[list_end][comment {--- arguments --}]

[comment {- - -- --- ----- -------- -------------}]
[call [cmd <config>] [method interact]]

This method invokes the mini-shell for interactive parameter entry.
It returns on exit from the shell.
The result of the method is the empty string.

[comment {- - -- --- ----- -------- -------------}]
[call [cmd <config>] [method interactive]]

This accessor method returns a boolean value indicating whether use
of the mini-shell is allowed ([const true]), or not ([const false]).

[comment {- - -- --- ----- -------- -------------}]
[call [cmd <config>] [method lookup] [arg name]]

This method checks if the configuration instance contains
a parameter with the specified [arg name] and returns its
instance. An error is thrown if the parameter is not known.

[list_begin arguments]
[arg_def string name]
The name of the parameter to retrieve.

[list_end][comment {--- arguments --}]

[comment {- - -- --- ----- -------- -------------}]
[call [cmd <config>] [method lookup-option] [arg name]]

This method checks if the configuration instance contains
a parameter controlling the specified option [arg name]
and returns its instance. An error is thrown if the option
is not known.

[list_begin arguments]
[arg_def string name]
The option flag to find the controlling parameter for.
[list_end][comment {--- arguments --}]

[comment {- - -- --- ----- -------- -------------}]
[call [cmd <config>] [method missingOptionValue] [arg name]]

This method throws the standard error for when the option [arg name]
requiring an argument value does not have one. See the
methods [method notEnough] and [method tooMany] as well.

[list_begin arguments]
[arg_def string name]
The flag triggering the error.

[list_end][comment {--- arguments --}]

[comment {- - -- --- ----- -------- -------------}]
[call [cmd <config>] [method names]]

This method returns a list of parameter names, for all parameters.

[comment {- - -- --- ----- -------- -------------}]
[call [cmd <config>] [method notEnough]]

This method throws the standard error for when a command is found
to be supplied with not enough arguments for its parameters. See
the methods [method missingOptionValue] and [method tooMany] as well.

[comment {- - -- --- ----- -------- -------------}]
[call [cmd <config>] [method options]]

This method returns a list of the option flags recognized
by the parameters in the configuration. This does not include
option prefixes.

[comment {- - -- --- ----- -------- -------------}]
[call [cmd <config>] [method parse] [opt [arg word...]]]

This method parses the words (from the command line) and
maps them to parameters, based on naming (options and flags),
or position (arguments).

[list_begin arguments]
[arg_def list word]
The words of the command specifying the parameters of the private
holding the configuration instance.

[list_end][comment {--- arguments --}]

[comment {- - -- --- ----- -------- -------------}]
[call [cmd <config>] [method parse-options]]

This method is a helper for [method parse] above.
Accessing the internal queue initialized by [method parse]
it splits arguments and options, processing all the latter.
The arguments are put back into the queue, in the order
they were found in.

This is used by parameters (optional arguments) using the
regular threshold-regime to determine acceptance. All options
still in the command line must be removed (and processed) to
know the proper number of arguments words left.

[comment {- - -- --- ----- -------- -------------}]
[call [cmd <config>] [method prompt1]]

This hook-method for the mini-shell returns the primary
prompt string to use.

[comment {- - -- --- ----- -------- -------------}]
[call [cmd <config>] [method prompt2]]

This hook-method for the mini-shell returns the secondary
prompt string for use within a continuation. As the mini-shell
does not support continuation lines it should not be invoked
ever, and thus always throws an error should it be invoked.

[comment {- - -- --- ----- -------- -------------}]
[call [cmd <config>] [method public]]

This method a list of parameter names, for all documented
option and argument parameters.

[comment {- - -- --- ----- -------- -------------}]
[call [cmd <config>] [method raise] [arg msg] [opt [arg word...]]]

This method is a helper for methods [method tooMany], [method notEnough],
and [method missingOptionValue], doing the bulk of the work.

[list_begin arguments]
[arg_def string msg] The human-readable error message to use.
[arg_def list word]  The machine-readable (trap-able) error code to use.
[list_end][comment {--- arguments --}]

[comment {- - -- --- ----- -------- -------------}]
[call [cmd <config>] [method report] [arg what] [arg data]]

This hook-method for the mini-shell is responsible for the
reporting of the command results and handles the display of
the parameter state before a new prompt.

[para] Its result is the empty string.

[list_begin arguments]
[arg_def enum what]
The result code of the command, one of [const ok], or [const fail].

[arg_def any data]
The result of the command, or an error message in case of failure.
[list_end][comment {--- arguments --}]

[comment {- - -- --- ----- -------- -------------}]
[call [cmd <config>] [method reset]]

This method invokes the parameter method [method reset] on all
parameters in the configuration.

[comment {- - -- --- ----- -------- -------------}]
[call [cmd <config>] [method self]]

This method returns the configuration instance itself.

[comment {- - -- --- ----- -------- -------------}]
[call [cmd <config>] [method tooMany]]

This method throws the standard error for when a command is found
to be supplied with too many arguments for its parameters. See the
methods [method missingOptionValue] and [method notEnough] as well.

[comment {- - -- --- ----- -------- -------------}]
[call [cmd <config>] [method unknown] [arg method] [opt [arg word...]]]

This method is the hook into the TclOO method resolution for the class.
It implements the dynamic accessor methods for the parameters held by
the configuration instance. See method [method @...] at the top.

[list_begin arguments]
[arg_def list list]
[list_end][comment {--- arguments --}]

[list_end][comment {-- definitions --}]


[comment @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@]
[section {Help Information}]
[include parts/help_structure.inc]

[include parts/feedback.inc]
[manpage_end]