cmdr
Check-in [5487358492]
Not logged in

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

Overview
Comment:Remade "help::query-actor" as method "find" of officers and private. Simplified the internals of auto-help. Provides the path lookup to framework users as well. Updated the documentation.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 548735849257a50c6813acd785a201a489269832
User & Date: aku 2014-02-06 06:18:19.922
Context
2014-02-06
17:39
Fixed issue in previous commit. New code failed to take a possible empty path into account. check-in: 8117b3db5e user: andreask tags: trunk
06:18
Remade "help::query-actor" as method "find" of officers and private. Simplified the internals of auto-help. Provides the path lookup to framework users as well. Updated the documentation. check-in: 5487358492 user: aku tags: trunk
06:00
Updated tests to match the new auto-exit command. check-in: 48291542b3 user: aku tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to doc/cmdr_officer.man.
195
196
197
198
199
200
201











202
203
204
205
206
207
208
The command prefix to invoke when this private is selected for
execution.  It takes a single argument, the instance command of the
hidden [package cmdr::config] container holding the private's
parameters. The result of the action, if there is any, is ignored by
the framework.

[list_end][comment arguments]












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

This method returns a boolean value indicating if this officer has a
sub-ordinate of the given [arg name] ([const true]), or not
([const false]). See also method [method lookup].







>
>
>
>
>
>
>
>
>
>
>







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
The command prefix to invoke when this private is selected for
execution.  It takes a single argument, the instance command of the
hidden [package cmdr::config] container holding the private's
parameters. The result of the action, if there is any, is ignored by
the framework.

[list_end][comment arguments]

[comment {- - -- --- ----- -------- -------------}]
[call [cmd <officer>] [method find] [arg path]]

This method returns the instance command of the sub-ordinate with the
given [arg path] of names. An error is thrown if such a sub-ordinate
does not exist. See also method [method has].

[list_begin arguments]
[arg_def string path] The path of names to the sub-ordinate to look for.
[list_end]

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

This method returns a boolean value indicating if this officer has a
sub-ordinate of the given [arg name] ([const true]), or not
([const false]). See also method [method lookup].
Changes to doc/cmdr_private.man.
115
116
117
118
119
120
121













122
123
124
125
126
127
128
prefix has to execute this script in its caller's context. The script
will parse words for the private,m and perform its action. The command
prefix then has the responsbility to perform any custom cleanup action
required by the application using the framework to prevent leakage of
data between multiple commands executed one after the other (i.e. in
an interactive shell run by the framework).
[list_end][comment arguments]














[comment {- - -- --- ----- -------- -------------}]
[call [cmd <private>] [method help] [opt [arg prefix]]]

This method returns the help information for the private and its
parameters. The [arg prefix], if specified provides the name of the
private within the help data. It defaults to the empty string.







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







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
prefix has to execute this script in its caller's context. The script
will parse words for the private,m and perform its action. The command
prefix then has the responsbility to perform any custom cleanup action
required by the application using the framework to prevent leakage of
data between multiple commands executed one after the other (i.e. in
an interactive shell run by the framework).
[list_end][comment arguments]

[comment {- - -- --- ----- -------- -------------}]
[call [cmd <private>] [method find] [arg path]]

This method returns the instance command of the sub-ordinate with the
given [arg path] of names. An error is thrown if such a sub-ordinate
does not exist, i.e. always, as a private has no sub-ordinates,
ever. See also method [method find] of [package cdmr::officer] for the
high-end of the recursion which may end in this method.

[list_begin arguments]
[arg_def string path] The path of names to the sub-ordinate to look for.
[list_end]

[comment {- - -- --- ----- -------- -------------}]
[call [cmd <private>] [method help] [opt [arg prefix]]]

This method returns the help information for the private and its
parameters. The [arg prefix], if specified provides the name of the
private within the help data. It defaults to the empty string.
Changes to embedded/man/files/cmdr_officer.n.
266
267
268
269
270
271
272


273
274
275
276
277
278
279
.sp
\fB<officer>\fR \fBehandler\fR \fIcmd\fR
.sp
\fB<officer>\fR \fBexit\fR
.sp
\fB<officer>\fR \fBextend\fR \fIpath\fR \fIarguments\fR \fIaction\fR
.sp


\fB<officer>\fR \fBhas\fR \fIname\fR
.sp
\fB<officer>\fR \fBhasdefault\fR
.sp
\fB<officer>\fR \fBhelp\fR ?\fIprefix\fR?
.sp
\fB<officer>\fR \fBknown\fR







>
>







266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
.sp
\fB<officer>\fR \fBehandler\fR \fIcmd\fR
.sp
\fB<officer>\fR \fBexit\fR
.sp
\fB<officer>\fR \fBextend\fR \fIpath\fR \fIarguments\fR \fIaction\fR
.sp
\fB<officer>\fR \fBfind\fR \fIpath\fR
.sp
\fB<officer>\fR \fBhas\fR \fIname\fR
.sp
\fB<officer>\fR \fBhasdefault\fR
.sp
\fB<officer>\fR \fBhelp\fR ?\fIprefix\fR?
.sp
\fB<officer>\fR \fBknown\fR
451
452
453
454
455
456
457










458
459
460
461
462
463
464
cmd-prefix \fIaction\fR
The command prefix to invoke when this private is selected for
execution\&.  It takes a single argument, the instance command of the
hidden \fBcmdr::config\fR container holding the private's
parameters\&. The result of the action, if there is any, is ignored by
the framework\&.
.RE










.TP
\fB<officer>\fR \fBhas\fR \fIname\fR
This method returns a boolean value indicating if this officer has a
sub-ordinate of the given \fIname\fR (\fBtrue\fR), or not
(\fBfalse\fR)\&. See also method \fBlookup\fR\&.
.RS
.TP







>
>
>
>
>
>
>
>
>
>







453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
cmd-prefix \fIaction\fR
The command prefix to invoke when this private is selected for
execution\&.  It takes a single argument, the instance command of the
hidden \fBcmdr::config\fR container holding the private's
parameters\&. The result of the action, if there is any, is ignored by
the framework\&.
.RE
.TP
\fB<officer>\fR \fBfind\fR \fIpath\fR
This method returns the instance command of the sub-ordinate with the
given \fIpath\fR of names\&. An error is thrown if such a sub-ordinate
does not exist\&. See also method \fBhas\fR\&.
.RS
.TP
string \fIpath\fR
The path of names to the sub-ordinate to look for\&.
.RE
.TP
\fB<officer>\fR \fBhas\fR \fIname\fR
This method returns a boolean value indicating if this officer has a
sub-ordinate of the given \fIname\fR (\fBtrue\fR), or not
(\fBfalse\fR)\&. See also method \fBlookup\fR\&.
.RS
.TP
Changes to embedded/man/files/cmdr_private.n.
251
252
253
254
255
256
257


258
259
260
261
262
263
264
\fB::cmdr::private\fR \fBcreate\fR \fIobj\fR \fIsuper\fR \fIname\fR \fIarguments\fR \fIaction\fR
.sp
\fB<private>\fR \fBcomplete-words\fR \fIparse\fR
.sp
\fB<private>\fR \fBdo\fR ?\fIword\fR\&.\&.\&.?
.sp
\fB<private>\fR \fBehandler\fR \fIcmd\fR


.sp
\fB<private>\fR \fBhelp\fR ?\fIprefix\fR?
.sp
\fB<private>\fR \fBunknown\fR \fIm\fR ?\fIword\fR\&.\&.\&.?
.sp
.BE
.SH DESCRIPTION







>
>







251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
\fB::cmdr::private\fR \fBcreate\fR \fIobj\fR \fIsuper\fR \fIname\fR \fIarguments\fR \fIaction\fR
.sp
\fB<private>\fR \fBcomplete-words\fR \fIparse\fR
.sp
\fB<private>\fR \fBdo\fR ?\fIword\fR\&.\&.\&.?
.sp
\fB<private>\fR \fBehandler\fR \fIcmd\fR
.sp
\fB<private>\fR \fBfind\fR \fIpath\fR
.sp
\fB<private>\fR \fBhelp\fR ?\fIprefix\fR?
.sp
\fB<private>\fR \fBunknown\fR \fIm\fR ?\fIword\fR\&.\&.\&.?
.sp
.BE
.SH DESCRIPTION
357
358
359
360
361
362
363












364
365
366
367
368
369
370
prefix has to execute this script in its caller's context\&. The script
will parse words for the private,m and perform its action\&. The command
prefix then has the responsbility to perform any custom cleanup action
required by the application using the framework to prevent leakage of
data between multiple commands executed one after the other (i\&.e\&. in
an interactive shell run by the framework)\&.
.RE












.TP
\fB<private>\fR \fBhelp\fR ?\fIprefix\fR?
This method returns the help information for the private and its
parameters\&. The \fIprefix\fR, if specified provides the name of the
private within the help data\&. It defaults to the empty string\&.
The result of the command is a structure of the form
described in section \fBHelp Information\fR\&.







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







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
prefix has to execute this script in its caller's context\&. The script
will parse words for the private,m and perform its action\&. The command
prefix then has the responsbility to perform any custom cleanup action
required by the application using the framework to prevent leakage of
data between multiple commands executed one after the other (i\&.e\&. in
an interactive shell run by the framework)\&.
.RE
.TP
\fB<private>\fR \fBfind\fR \fIpath\fR
This method returns the instance command of the sub-ordinate with the
given \fIpath\fR of names\&. An error is thrown if such a sub-ordinate
does not exist, i\&.e\&. always, as a private has no sub-ordinates,
ever\&. See also method \fBfind\fR of \fBcdmr::officer\fR for the
high-end of the recursion which may end in this method\&.
.RS
.TP
string \fIpath\fR
The path of names to the sub-ordinate to look for\&.
.RE
.TP
\fB<private>\fR \fBhelp\fR ?\fIprefix\fR?
This method returns the help information for the private and its
parameters\&. The \fIprefix\fR, if specified provides the name of the
private within the help data\&. It defaults to the empty string\&.
The result of the command is a structure of the form
described in section \fBHelp Information\fR\&.
Changes to embedded/www/doc/files/cmdr_officer.html.
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151

152
153
154
155
156
157
158
159
<li><a href="#6"><b class="cmd">&lt;officer&gt;</b> <b class="method">continued</b> <i class="arg">line</i></a></li>
<li><a href="#7"><b class="cmd">&lt;officer&gt;</b> <b class="method">default</b></a></li>
<li><a href="#8"><b class="cmd">&lt;officer&gt;</b> <b class="method">dispatch</b> <i class="arg">cmd</i></a></li>
<li><a href="#9"><b class="cmd">&lt;officer&gt;</b> <b class="method">do</b> <span class="opt">?<i class="arg">word</i>...?</span></a></li>
<li><a href="#10"><b class="cmd">&lt;officer&gt;</b> <b class="method">ehandler</b> <i class="arg">cmd</i></a></li>
<li><a href="#11"><b class="cmd">&lt;officer&gt;</b> <b class="method">exit</b></a></li>
<li><a href="#12"><b class="cmd">&lt;officer&gt;</b> <b class="method">extend</b> <i class="arg">path</i> <i class="arg">arguments</i> <i class="arg">action</i></a></li>
<li><a href="#13"><b class="cmd">&lt;officer&gt;</b> <b class="method">has</b> <i class="arg">name</i></a></li>
<li><a href="#14"><b class="cmd">&lt;officer&gt;</b> <b class="method">hasdefault</b></a></li>
<li><a href="#15"><b class="cmd">&lt;officer&gt;</b> <b class="method">help</b> <span class="opt">?<i class="arg">prefix</i>?</span></a></li>
<li><a href="#16"><b class="cmd">&lt;officer&gt;</b> <b class="method">known</b></a></li>
<li><a href="#17"><b class="cmd">&lt;officer&gt;</b> <b class="method">learn</b> <i class="arg">script</i></a></li>
<li><a href="#18"><b class="cmd">&lt;officer&gt;</b> <b class="method">lookup</b> <i class="arg">name</i></a></li>
<li><a href="#19"><b class="cmd">&lt;officer&gt;</b> <b class="method">prompt1</b></a></li>
<li><a href="#20"><b class="cmd">&lt;officer&gt;</b> <b class="method">prompt2</b></a></li>
<li><a href="#21"><b class="cmd">&lt;officer&gt;</b> <b class="method">report</b> <i class="arg">what</i> <i class="arg">data</i></a></li>

<li><a href="#22"><b class="cmd">&lt;officer&gt;</b> <b class="method">shell-exit</b> <i class="arg">config</i></a></li>
</ul>
</div>
</div>
<div id="section1" class="section"><h2><a name="section1">Description</a></h2>
<p>Welcome to the Cmdr project, written by Andreas Kupries.</p>
<p>For availability please read <i class="term"><a href="cmdr_howto_get_sources.html">Cmdr - How To Get The Sources</a></i>.</p>
<p>This package implements <em>officers</em>, the inner nodes of command







|
|
|
|
|
|
|
|
|
>
|







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
<li><a href="#6"><b class="cmd">&lt;officer&gt;</b> <b class="method">continued</b> <i class="arg">line</i></a></li>
<li><a href="#7"><b class="cmd">&lt;officer&gt;</b> <b class="method">default</b></a></li>
<li><a href="#8"><b class="cmd">&lt;officer&gt;</b> <b class="method">dispatch</b> <i class="arg">cmd</i></a></li>
<li><a href="#9"><b class="cmd">&lt;officer&gt;</b> <b class="method">do</b> <span class="opt">?<i class="arg">word</i>...?</span></a></li>
<li><a href="#10"><b class="cmd">&lt;officer&gt;</b> <b class="method">ehandler</b> <i class="arg">cmd</i></a></li>
<li><a href="#11"><b class="cmd">&lt;officer&gt;</b> <b class="method">exit</b></a></li>
<li><a href="#12"><b class="cmd">&lt;officer&gt;</b> <b class="method">extend</b> <i class="arg">path</i> <i class="arg">arguments</i> <i class="arg">action</i></a></li>
<li><a href="#13"><b class="cmd">&lt;officer&gt;</b> <b class="method">find</b> <i class="arg">path</i></a></li>
<li><a href="#14"><b class="cmd">&lt;officer&gt;</b> <b class="method">has</b> <i class="arg">name</i></a></li>
<li><a href="#15"><b class="cmd">&lt;officer&gt;</b> <b class="method">hasdefault</b></a></li>
<li><a href="#16"><b class="cmd">&lt;officer&gt;</b> <b class="method">help</b> <span class="opt">?<i class="arg">prefix</i>?</span></a></li>
<li><a href="#17"><b class="cmd">&lt;officer&gt;</b> <b class="method">known</b></a></li>
<li><a href="#18"><b class="cmd">&lt;officer&gt;</b> <b class="method">learn</b> <i class="arg">script</i></a></li>
<li><a href="#19"><b class="cmd">&lt;officer&gt;</b> <b class="method">lookup</b> <i class="arg">name</i></a></li>
<li><a href="#20"><b class="cmd">&lt;officer&gt;</b> <b class="method">prompt1</b></a></li>
<li><a href="#21"><b class="cmd">&lt;officer&gt;</b> <b class="method">prompt2</b></a></li>
<li><a href="#22"><b class="cmd">&lt;officer&gt;</b> <b class="method">report</b> <i class="arg">what</i> <i class="arg">data</i></a></li>
<li><a href="#23"><b class="cmd">&lt;officer&gt;</b> <b class="method">shell-exit</b> <i class="arg">config</i></a></li>
</ul>
</div>
</div>
<div id="section1" class="section"><h2><a name="section1">Description</a></h2>
<p>Welcome to the Cmdr project, written by Andreas Kupries.</p>
<p>For availability please read <i class="term"><a href="cmdr_howto_get_sources.html">Cmdr - How To Get The Sources</a></i>.</p>
<p>This package implements <em>officers</em>, the inner nodes of command
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
<dt>cmd-prefix <i class="arg">action</i></dt>
<dd><p>The command prefix to invoke when this private is selected for
execution.  It takes a single argument, the instance command of the
hidden <b class="package"><a href="cmdr_config.html">cmdr::config</a></b> container holding the private's
parameters. The result of the action, if there is any, is ignored by
the framework.</p></dd>
</dl></dd>
<dt><a name="13"><b class="cmd">&lt;officer&gt;</b> <b class="method">has</b> <i class="arg">name</i></a></dt>








<dd><p>This method returns a boolean value indicating if this officer has a
sub-ordinate of the given <i class="arg">name</i> (<b class="const">true</b>), or not
(<b class="const">false</b>). See also method <b class="method">lookup</b>.</p>
<dl class="arguments">
<dt>string <i class="arg">name</i></dt>
<dd><p>The name of the sub-ordinate to look for.</p></dd>
</dl></dd>
<dt><a name="14"><b class="cmd">&lt;officer&gt;</b> <b class="method">hasdefault</b></a></dt>
<dd><p>This method returns a boolean value indicating if this officer has a
default sub-ordinate (<b class="const">true</b>), or not (<b class="const">false</b>). See also
method <b class="method">default</b>.</p></dd>
<dt><a name="15"><b class="cmd">&lt;officer&gt;</b> <b class="method">help</b> <span class="opt">?<i class="arg">prefix</i>?</span></a></dt>
<dd><p>This method returns the help information for the officer and its
subordinates. The <i class="arg">prefix</i>, if specified provides the name of the
officer within the help data. It defaults to the empty string.
The result of the command is a structure of the form
described in section <span class="sectref"><a href="#section4">Help Information</a></span>.</p>
<dl class="arguments">
<dt>string <i class="arg">prefix</i></dt>
<dd><p>The name to use for the officer within the generated help.</p></dd>
</dl></dd>
<dt><a name="16"><b class="cmd">&lt;officer&gt;</b> <b class="method">known</b></a></dt>
<dd><p>This method returns a list containing the names of the subordinate
actors managed by this officer.
See also method <b class="method">children</b> which returns a list of instance
commands.
See also method <b class="method">lookup</b> to map names to instance commands.</p></dd>
<dt><a name="17"><b class="cmd">&lt;officer&gt;</b> <b class="method">learn</b> <i class="arg">script</i></a></dt>
<dd><p>This method takes a regular specification script and uses it to extend
the set of subordinates known to this officer. This is the same type
of script as used during construction, except here we dynamically
extend the officer.</p>
<dl class="arguments">
<dt>script <i class="arg">actions</i></dt>
<dd><p>The specification of the officer's additional subordinates.
Please read <i class="term"><a href="cmdr_dsl_officer.html">Cmdr - Officer Specification Language</a></i> for the details.</p></dd>
</dl></dd>
<dt><a name="18"><b class="cmd">&lt;officer&gt;</b> <b class="method">lookup</b> <i class="arg">name</i></a></dt>
<dd><p>This method returns the instance command of the sub-ordinate with the
given <i class="arg">name</i>. An error is thrown if such a sub-ordinate does not
exist. See also method <b class="method">has</b>.</p>
<dl class="arguments">
<dt>string <i class="arg">name</i></dt>
<dd><p>The name of the sub-ordinate to look for.</p></dd>
</dl></dd>
<dt><a name="19"><b class="cmd">&lt;officer&gt;</b> <b class="method">prompt1</b></a></dt>
<dd><p>This hook-method for the main shell returns the primary prompt string
to use.</p></dd>
<dt><a name="20"><b class="cmd">&lt;officer&gt;</b> <b class="method">prompt2</b></a></dt>
<dd><p>This hook-method for the main shell returns the secondary prompt
string for use within a continuation. As the main shell does not
support continuation lines it should not be invoked ever, and thus
always throws an error should it be invoked.</p></dd>
<dt><a name="21"><b class="cmd">&lt;officer&gt;</b> <b class="method">report</b> <i class="arg">what</i> <i class="arg">data</i></a></dt>
<dd><p>This hook-method for the main shell is responsible for the reporting
of the command results.</p>
<p>Its result is the empty string.</p>
<dl class="arguments">
<dt>enum <i class="arg">what</i></dt>
<dd><p>The result code of the command, one of <b class="const">ok</b>, or <b class="const">fail</b>.</p></dd>
<dt>any <i class="arg">data</i></dt>
<dd><p>The result of the command, or an error message in case of failure.</p></dd>
</dl></dd>
<dt><a name="22"><b class="cmd">&lt;officer&gt;</b> <b class="method">shell-exit</b> <i class="arg">config</i></a></dt>
<dd><p>This is the backend for a private ending the main shell,
be it automatically created by the pacge, or by a user.</p>
<p>The argument is the <b class="package"><a href="cmdr_config.html">cmdr::config</a></b>
instance holding the parameters. The method does not
expect any and ignore it.</p></dd>
</dl>
</div>







|
>
>
>
>
>
>
>
>







|



|









|





|









|







|


|




|









|







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
<dt>cmd-prefix <i class="arg">action</i></dt>
<dd><p>The command prefix to invoke when this private is selected for
execution.  It takes a single argument, the instance command of the
hidden <b class="package"><a href="cmdr_config.html">cmdr::config</a></b> container holding the private's
parameters. The result of the action, if there is any, is ignored by
the framework.</p></dd>
</dl></dd>
<dt><a name="13"><b class="cmd">&lt;officer&gt;</b> <b class="method">find</b> <i class="arg">path</i></a></dt>
<dd><p>This method returns the instance command of the sub-ordinate with the
given <i class="arg">path</i> of names. An error is thrown if such a sub-ordinate
does not exist. See also method <b class="method">has</b>.</p>
<dl class="arguments">
<dt>string <i class="arg">path</i></dt>
<dd><p>The path of names to the sub-ordinate to look for.</p></dd>
</dl></dd>
<dt><a name="14"><b class="cmd">&lt;officer&gt;</b> <b class="method">has</b> <i class="arg">name</i></a></dt>
<dd><p>This method returns a boolean value indicating if this officer has a
sub-ordinate of the given <i class="arg">name</i> (<b class="const">true</b>), or not
(<b class="const">false</b>). See also method <b class="method">lookup</b>.</p>
<dl class="arguments">
<dt>string <i class="arg">name</i></dt>
<dd><p>The name of the sub-ordinate to look for.</p></dd>
</dl></dd>
<dt><a name="15"><b class="cmd">&lt;officer&gt;</b> <b class="method">hasdefault</b></a></dt>
<dd><p>This method returns a boolean value indicating if this officer has a
default sub-ordinate (<b class="const">true</b>), or not (<b class="const">false</b>). See also
method <b class="method">default</b>.</p></dd>
<dt><a name="16"><b class="cmd">&lt;officer&gt;</b> <b class="method">help</b> <span class="opt">?<i class="arg">prefix</i>?</span></a></dt>
<dd><p>This method returns the help information for the officer and its
subordinates. The <i class="arg">prefix</i>, if specified provides the name of the
officer within the help data. It defaults to the empty string.
The result of the command is a structure of the form
described in section <span class="sectref"><a href="#section4">Help Information</a></span>.</p>
<dl class="arguments">
<dt>string <i class="arg">prefix</i></dt>
<dd><p>The name to use for the officer within the generated help.</p></dd>
</dl></dd>
<dt><a name="17"><b class="cmd">&lt;officer&gt;</b> <b class="method">known</b></a></dt>
<dd><p>This method returns a list containing the names of the subordinate
actors managed by this officer.
See also method <b class="method">children</b> which returns a list of instance
commands.
See also method <b class="method">lookup</b> to map names to instance commands.</p></dd>
<dt><a name="18"><b class="cmd">&lt;officer&gt;</b> <b class="method">learn</b> <i class="arg">script</i></a></dt>
<dd><p>This method takes a regular specification script and uses it to extend
the set of subordinates known to this officer. This is the same type
of script as used during construction, except here we dynamically
extend the officer.</p>
<dl class="arguments">
<dt>script <i class="arg">actions</i></dt>
<dd><p>The specification of the officer's additional subordinates.
Please read <i class="term"><a href="cmdr_dsl_officer.html">Cmdr - Officer Specification Language</a></i> for the details.</p></dd>
</dl></dd>
<dt><a name="19"><b class="cmd">&lt;officer&gt;</b> <b class="method">lookup</b> <i class="arg">name</i></a></dt>
<dd><p>This method returns the instance command of the sub-ordinate with the
given <i class="arg">name</i>. An error is thrown if such a sub-ordinate does not
exist. See also method <b class="method">has</b>.</p>
<dl class="arguments">
<dt>string <i class="arg">name</i></dt>
<dd><p>The name of the sub-ordinate to look for.</p></dd>
</dl></dd>
<dt><a name="20"><b class="cmd">&lt;officer&gt;</b> <b class="method">prompt1</b></a></dt>
<dd><p>This hook-method for the main shell returns the primary prompt string
to use.</p></dd>
<dt><a name="21"><b class="cmd">&lt;officer&gt;</b> <b class="method">prompt2</b></a></dt>
<dd><p>This hook-method for the main shell returns the secondary prompt
string for use within a continuation. As the main shell does not
support continuation lines it should not be invoked ever, and thus
always throws an error should it be invoked.</p></dd>
<dt><a name="22"><b class="cmd">&lt;officer&gt;</b> <b class="method">report</b> <i class="arg">what</i> <i class="arg">data</i></a></dt>
<dd><p>This hook-method for the main shell is responsible for the reporting
of the command results.</p>
<p>Its result is the empty string.</p>
<dl class="arguments">
<dt>enum <i class="arg">what</i></dt>
<dd><p>The result code of the command, one of <b class="const">ok</b>, or <b class="const">fail</b>.</p></dd>
<dt>any <i class="arg">data</i></dt>
<dd><p>The result of the command, or an error message in case of failure.</p></dd>
</dl></dd>
<dt><a name="23"><b class="cmd">&lt;officer&gt;</b> <b class="method">shell-exit</b> <i class="arg">config</i></a></dt>
<dd><p>This is the backend for a private ending the main shell,
be it automatically created by the pacge, or by a user.</p>
<p>The argument is the <b class="package"><a href="cmdr_config.html">cmdr::config</a></b>
instance holding the parameters. The method does not
expect any and ignore it.</p></dd>
</dl>
</div>
Changes to embedded/www/doc/files/cmdr_private.html.
129
130
131
132
133
134
135

136
137
138
139
140
141
142
143
144
</ul>
<ul class="syntax">
<li><a href="#1"><b class="cmd">::cmdr::private</b> <b class="method">new</b> <i class="arg">super</i> <i class="arg">name</i> <i class="arg">arguments</i> <i class="arg">action</i></a></li>
<li><a href="#2"><b class="cmd">::cmdr::private</b> <b class="method">create</b> <i class="arg">obj</i> <i class="arg">super</i> <i class="arg">name</i> <i class="arg">arguments</i> <i class="arg">action</i></a></li>
<li><a href="#3"><b class="cmd">&lt;private&gt;</b> <b class="method">complete-words</b> <i class="arg">parse</i></a></li>
<li><a href="#4"><b class="cmd">&lt;private&gt;</b> <b class="method">do</b> <span class="opt">?<i class="arg">word</i>...?</span></a></li>
<li><a href="#5"><b class="cmd">&lt;private&gt;</b> <b class="method">ehandler</b> <i class="arg">cmd</i></a></li>

<li><a href="#6"><b class="cmd">&lt;private&gt;</b> <b class="method">help</b> <span class="opt">?<i class="arg">prefix</i>?</span></a></li>
<li><a href="#7"><b class="cmd">&lt;private&gt;</b> <b class="method">unknown</b> <i class="arg">m</i> <span class="opt">?<i class="arg">word</i>...?</span></a></li>
</ul>
</div>
</div>
<div id="section1" class="section"><h2><a name="section1">Description</a></h2>
<p>Welcome to the Cmdr project, written by Andreas Kupries.</p>
<p>For availability please read <i class="term"><a href="cmdr_howto_get_sources.html">Cmdr - How To Get The Sources</a></i>.</p>
<p>This package implements <em>privates</em>, the leaves of command







>
|
|







129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
</ul>
<ul class="syntax">
<li><a href="#1"><b class="cmd">::cmdr::private</b> <b class="method">new</b> <i class="arg">super</i> <i class="arg">name</i> <i class="arg">arguments</i> <i class="arg">action</i></a></li>
<li><a href="#2"><b class="cmd">::cmdr::private</b> <b class="method">create</b> <i class="arg">obj</i> <i class="arg">super</i> <i class="arg">name</i> <i class="arg">arguments</i> <i class="arg">action</i></a></li>
<li><a href="#3"><b class="cmd">&lt;private&gt;</b> <b class="method">complete-words</b> <i class="arg">parse</i></a></li>
<li><a href="#4"><b class="cmd">&lt;private&gt;</b> <b class="method">do</b> <span class="opt">?<i class="arg">word</i>...?</span></a></li>
<li><a href="#5"><b class="cmd">&lt;private&gt;</b> <b class="method">ehandler</b> <i class="arg">cmd</i></a></li>
<li><a href="#6"><b class="cmd">&lt;private&gt;</b> <b class="method">find</b> <i class="arg">path</i></a></li>
<li><a href="#7"><b class="cmd">&lt;private&gt;</b> <b class="method">help</b> <span class="opt">?<i class="arg">prefix</i>?</span></a></li>
<li><a href="#8"><b class="cmd">&lt;private&gt;</b> <b class="method">unknown</b> <i class="arg">m</i> <span class="opt">?<i class="arg">word</i>...?</span></a></li>
</ul>
</div>
</div>
<div id="section1" class="section"><h2><a name="section1">Description</a></h2>
<p>Welcome to the Cmdr project, written by Andreas Kupries.</p>
<p>For availability please read <i class="term"><a href="cmdr_howto_get_sources.html">Cmdr - How To Get The Sources</a></i>.</p>
<p>This package implements <em>privates</em>, the leaves of command
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
prefix has to execute this script in its caller's context. The script
will parse words for the private,m and perform its action. The command
prefix then has the responsbility to perform any custom cleanup action
required by the application using the framework to prevent leakage of
data between multiple commands executed one after the other (i.e. in
an interactive shell run by the framework).</p></dd>
</dl></dd>










<dt><a name="6"><b class="cmd">&lt;private&gt;</b> <b class="method">help</b> <span class="opt">?<i class="arg">prefix</i>?</span></a></dt>
<dd><p>This method returns the help information for the private and its
parameters. The <i class="arg">prefix</i>, if specified provides the name of the
private within the help data. It defaults to the empty string.
The result of the command is a structure of the form
described in section <span class="sectref"><a href="#section4">Help Information</a></span>.</p>
<dl class="arguments">
<dt>string <i class="arg">prefix</i></dt>
<dd><p>The name to use for the private within the generated help.</p></dd>
</dl></dd>
<dt><a name="7"><b class="cmd">&lt;private&gt;</b> <b class="method">unknown</b> <i class="arg">m</i> <span class="opt">?<i class="arg">word</i>...?</span></a></dt>
<dd><p>This method overrides the standard behaviour for unknown methods.
Instead of throwing an error they are routed to the hidden container
of the private's parameters, of class <b class="package"><a href="cmdr_config.html">cmdr::config</a></b>.</p>
<dl class="arguments">
<dt>string <i class="arg">m</i></dt>
<dd><p>The name of the unknown method.</p></dd>
<dt>string <i class="arg">word</i></dt>







>
>
>
>
>
>
>
>
>
>
|









|







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
prefix has to execute this script in its caller's context. The script
will parse words for the private,m and perform its action. The command
prefix then has the responsbility to perform any custom cleanup action
required by the application using the framework to prevent leakage of
data between multiple commands executed one after the other (i.e. in
an interactive shell run by the framework).</p></dd>
</dl></dd>
<dt><a name="6"><b class="cmd">&lt;private&gt;</b> <b class="method">find</b> <i class="arg">path</i></a></dt>
<dd><p>This method returns the instance command of the sub-ordinate with the
given <i class="arg">path</i> of names. An error is thrown if such a sub-ordinate
does not exist, i.e. always, as a private has no sub-ordinates,
ever. See also method <b class="method">find</b> of <b class="package">cdmr::officer</b> for the
high-end of the recursion which may end in this method.</p>
<dl class="arguments">
<dt>string <i class="arg">path</i></dt>
<dd><p>The path of names to the sub-ordinate to look for.</p></dd>
</dl></dd>
<dt><a name="7"><b class="cmd">&lt;private&gt;</b> <b class="method">help</b> <span class="opt">?<i class="arg">prefix</i>?</span></a></dt>
<dd><p>This method returns the help information for the private and its
parameters. The <i class="arg">prefix</i>, if specified provides the name of the
private within the help data. It defaults to the empty string.
The result of the command is a structure of the form
described in section <span class="sectref"><a href="#section4">Help Information</a></span>.</p>
<dl class="arguments">
<dt>string <i class="arg">prefix</i></dt>
<dd><p>The name to use for the private within the generated help.</p></dd>
</dl></dd>
<dt><a name="8"><b class="cmd">&lt;private&gt;</b> <b class="method">unknown</b> <i class="arg">m</i> <span class="opt">?<i class="arg">word</i>...?</span></a></dt>
<dd><p>This method overrides the standard behaviour for unknown methods.
Instead of throwing an error they are routed to the hidden container
of the private's parameters, of class <b class="package"><a href="cmdr_config.html">cmdr::config</a></b>.</p>
<dl class="arguments">
<dt>string <i class="arg">m</i></dt>
<dd><p>The name of the unknown method.</p></dd>
<dt>string <i class="arg">word</i></dt>
Changes to help.tcl.
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

namespace eval ::cmdr {
    namespace export help
    namespace ensemble create
}

namespace eval ::cmdr::help {
    namespace export query query-actor format auto
    namespace ensemble create
}

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

proc ::cmdr::help::query {actor words} {
    debug.cmdr/help {}
    # Resolve chain of words (command name path) to the actor
    # responsible for that command, starting from the specified actor.
    # This is very much a convenience command.

    set root   [$actor root]
    set prefix $words

    if {![$root exists *in-shell*] ||
	![$root get    *in-shell*]} {
	# Not in the shell, put executable's name into the prefix.
	set prefix [linsert $prefix 0 [$root name]]
    }

    return [[query-actor $actor $words] help $prefix]
}

proc ::cmdr::help::query-actor {actor words} {
    debug.cmdr/help {}
    # Resolve chain of words (command name path) to the actor
    # responsible for that command, starting from the specified actor.
    # This is very much a convenience command.

    set n -1
    foreach word $words {
	if {[info object class $actor] ne "::cmdr::officer"} {
	    # Privates do not have subordinates to look up.
	    # We now have a bad command name argument to help.

	    set prefix [lrange $words 0 $n]
	    return -code error \
		-errorcode [list CMDR ACTION BAD $word] \
		"The command \"$prefix\" has no sub-commands, unexpected word \"$word\""
	}

	set actor [$actor lookup $word]
	incr n
    }

    return $actor
}

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

proc ::cmdr::help::auto {actor} {
    debug.cmdr/help {}
    # Generate a standard help command for any actor, and add it dynamically.







|




















|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







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

namespace eval ::cmdr {
    namespace export help
    namespace ensemble create
}

namespace eval ::cmdr::help {
    namespace export query format auto
    namespace ensemble create
}

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

proc ::cmdr::help::query {actor words} {
    debug.cmdr/help {}
    # Resolve chain of words (command name path) to the actor
    # responsible for that command, starting from the specified actor.
    # This is very much a convenience command.

    set root   [$actor root]
    set prefix $words

    if {![$root exists *in-shell*] ||
	![$root get    *in-shell*]} {
	# Not in the shell, put executable's name into the prefix.
	set prefix [linsert $prefix 0 [$root name]]
    }

    return [[$actor find $words] help $prefix]

























}

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

proc ::cmdr::help::auto {actor} {
    debug.cmdr/help {}
    # Generate a standard help command for any actor, and add it dynamically.
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
    debug.cmdr/help {}

    set width  [$config @width]
    set words  [$config @cmdname]
    set format [$config @format]

    if {$format eq {}} {
	# Default depends on the presence of additional arguments, i.e. if a specific command is asked for, or not.

	if {[llength $words]} {
	    set format full
	} else {
	    set format by-category
	}
    }

    puts [format $format [$actor root] $width [cmdr util dictsort [query $actor $words]]]




    return
}

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

namespace eval ::cmdr::help::format {
    namespace export full list short by-category
    namespace ensemble create

    namespace import ::cmdr::help::query
    namespace import ::cmdr::help::query-actor
}

# Alternate formats:
# List
# Short
# By-Category
# ... entirely different formats (json, .rst, docopts, ...)







|
>







|
>
>
>
>








<
<
<







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
    debug.cmdr/help {}

    set width  [$config @width]
    set words  [$config @cmdname]
    set format [$config @format]

    if {$format eq {}} {
	# Default depends on the presence of additional arguments,
	# i.e. if a specific command is asked for, or not.
	if {[llength $words]} {
	    set format full
	} else {
	    set format by-category
	}
    }

    puts [format $format \
	      [$actor root] \
	      $width \
	      [cmdr util dictsort \
		   [query $actor $words]]]
    return
}

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

namespace eval ::cmdr::help::format {
    namespace export full list short by-category
    namespace ensemble create



}

# Alternate formats:
# List
# Short
# By-Category
# ... entirely different formats (json, .rst, docopts, ...)
531
532
533
534
535
536
537
538

    return $categories
}


# # ## ### ##### ######## ############# #####################
## Ready
package provide cmdr::help 1.0.1







|
508
509
510
511
512
513
514
515

    return $categories
}


# # ## ### ##### ######## ############# #####################
## Ready
package provide cmdr::help 1.1
Changes to officer.tcl.
130
131
132
133
134
135
136




















137
138
139
140
141
142
143
	if {![dict exists $mymap a,$name]} {
	    return -code error \
		-errorcode [list CMDR ACTION UNKNOWN $name] \
		"Expected action name, got \"$name\""
	}
	return [dict get $mymap a,$name]
    }





















    method has {name} {
	debug.cmdr/officer {}
	my Setup
	return [dict exists $mymap a,$name]
    }








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







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
	if {![dict exists $mymap a,$name]} {
	    return -code error \
		-errorcode [list CMDR ACTION UNKNOWN $name] \
		"Expected action name, got \"$name\""
	}
	return [dict get $mymap a,$name]
    }

    method find {words} {
	# Resolve chain of words (command name path) to the actor
	# responsible for that command, starting from the current
	# actor.  This is very much a convenience method built on top
	# of lookup (see above).

	my _find $words {}
    }

    method _find {words prefix} {
	set word [lindex $words 0]
	if {[llength $words] <= 1} {
	    return [my lookup $word]
	}

	[my lookup $word] _find \
	    [lrange $words 1 end] \
	    [linsert $prefix end $word]
    }

    method has {name} {
	debug.cmdr/officer {}
	my Setup
	return [dict exists $mymap a,$name]
    }

637
638
639
640
641
642
643
644
	myreplexit myhandler

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

# # ## ### ##### ######## ############# #####################
## Ready
package provide cmdr::officer 1.0







|
657
658
659
660
661
662
663
664
	myreplexit myhandler

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

# # ## ### ##### ######## ############# #####################
## Ready
package provide cmdr::officer 1.1
Changes to private.tcl.
66
67
68
69
70
71
72















73
74
75
76
77
78
79
	set myinit      0
	set myhandler   {}
	return
    }

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
















    method ehandler {cmd} {
	debug.cmdr/private {}
	set myhandler $cmd
	return
    }

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







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







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
	set myinit      0
	set myhandler   {}
	return
    }

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

    method find {words} {
	my _find $words {}
    }

    method _find {words prefix} {
	# Privates do not have subordinates to look up.
	# We now have a bad command name argument to help.
	set word  [lindex $words 0]
	return -code error \
	    -errorcode [list CMDR ACTION BAD $word] \
	    "The command \"$prefix\" has no sub-commands, unexpected word \"$word\""
    }

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

    method ehandler {cmd} {
	debug.cmdr/private {}
	set myhandler $cmd
	return
    }

    # # ## ### ##### ######## #############
165
166
167
168
169
170
171
172
    variable myarguments mycmd myinit myconfig myhandler

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

# # ## ### ##### ######## ############# #####################
## Ready
package provide cmdr::private 1.0







|
180
181
182
183
184
185
186
187
    variable myarguments mycmd myinit myconfig myhandler

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

# # ## ### ##### ######## ############# #####################
## Ready
package provide cmdr::private 1.1