Check-in [de736eef56]

Not logged in

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

Overview
Comment:Continued conversion. Complete enough to be testable.
Timelines: family | ancestors | descendants | both | v2
Files: files | file ages | folders
SHA1:de736eef56e7b5a48ec00c92330b39ccb9312b7a
User & Date: andreask 2014-01-30 02:14:39
Context
2014-01-30
18:15
Updated local copy of Cmdr. check-in: 083ec0a2c3 user: andreask tags: v2
02:14
Continued conversion. Complete enough to be testable. check-in: de736eef56 user: andreask tags: v2
2013-12-20
01:33
Continued conversion of the doc templating commands to the new cli check-in: a8ba8c3cc5 user: andreask tags: v2
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to special.tcl.

20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
..
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
...
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
...
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
...
203
204
205
206
207
208
209




210
211
212
213
214
215
216
...
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
...
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
}

# # ## ### ##### ######## ############# #####################
## API

kettle cli extend setup  {
    section {Project Management}

    description {
	Generate a basic build control file in the current working
	directory. The arguments, if any, name the API commands
	to put into the file. Defaults to 'tcl'.
    }
    input args {
	The DSL commands to place into the generated file.
................................................................................
    return
}

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

kettle cli extend {doc setup} {
    section {Project Management} Documentation

    description {
	Generates a basic documentation setup for the named
	project, in the current working directory. If the
	project is not named the last part of the directory
	name is used as default.

	Use 'doc configure', etc. to query and (re)configure
................................................................................
    DocConfigure \
	project   $pname \
	ptitle    $ptitle \
	copyright [clock format [clock seconds] -format %Y]

    meta get-vc-information [pwd] m
    if {[dict get $m vc::system] ne "unknown"} {
	doc-config vc_type [dict get $m vc::system]
    }

    # consolidate within meta, extend to git.
    if {[path find.fossil [pwd]] ne {}} {
	set remote [exec {*}[auto_execok fossil] remote]
	regsub {/[^@]*@} $remote {/} remote
	doc-config repository $remote
    }

    # 3. Place standard license (BSD).
    # 4. Place standard requirement (Tcl 8.5).
    # 5. Place standard requirement (Kettle build system).

    io puts ""
................................................................................

    io puts ""
    return
}

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

kettle cli extend {doc edit-hooks} {
    section {Project Management} Documentation

    description {
	Show all places in the generated documentation where the user
	can and should edit it to suit the project.
    }
} ::kettle::special::DocEditHooks
................................................................................
    }
    input args {
	The keys and values to set, or the key to query.
    } {
	optional ; list ; validate str
    }
} [lambda config {




    ::kettle::special::DocConfigure {*}[$config @args]
}]

proc ::kettle::special::DocConfigure {args} {
    variable cfgfile
    set theconfig [path norm $cfgfile]
    set data [Decode [path cat $theconfig]]
................................................................................
	     [dict merge \
		  [DecodeConfig [dict get $data config]] \
		  $args]]
    path write $theconfig [Encode $data vset]
    return
}








return


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

::kettle::special::Def licenses? {} {



    List the licenses we can apply to the project.
} {




    foreach license [glob -directory [License] -tails *.inc] {
	set license [file rootname $license]
	io puts "  $license"
    }
    return
}

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

::kettle::special::Def license {{name {}}} {



    Set or query the license to use for the project.



} {
    variable docbase


    if {$name eq {}} {
	doc-config license
	return

    }





    io puts ""
    io puts "Configuring license ..."


    set src [License ${name}.inc]
    set dst [path norm $docbase/parts/license.inc]

    if {![file exists $src]} {
	io err {
	    io puts "  No file found for license: $name"
	}
	return
    }

    PlacePart $src $dst
    doc-config license $name














    return
}

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

::kettle::special::Def requirements? {} {



    List the requirements text-blocks we can apply to the project.
} {




    foreach rq [lsort -dict [glob -directory [Require] -tails *.inc]] {
	set rq [file rootname $rq]
	io puts "  $rq"
    }
    return
}

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

::kettle::special::Def requirements {} {


    List the requirements currently applied to the project.
} {




    set d [ReadRequirements]
    dict with d {} ; # header, config
    foreach rq $config {
	puts \t$rq
    }
    return
}

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

::kettle::special::Def requirements= {args} {


    Set the requirements which apply to the project.




} {
    variable docbase









    set d [ReadRequirements]
    dict set d config $args

    io puts ""
    io puts "Setting requirements ..."




    foreach rq $args {
	set src [Require $rq.inc]
	set dst [path norm $docbase/parts/rq_${rq}.inc]

	if {![file exists $src]} {
	    io err {
................................................................................
    }
    WriteRequirements $d
    return
}

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

::kettle::special::Def keywords {} {


    List the common keywords currently applied to the project.
} {




    set d [ReadKeywords]
    dict with d {} ; # header, config
    foreach kw [lsort -dict $config] {
	puts \t$kw
    }
    return
}

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

::kettle::special::Def keywords= {args} {


    Set the common keywords which apply to the project.




} {








    set d [ReadKeywords]
    dict set d config $args
    WriteKeywords $d
    return
}

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

::kettle::special::Def keywords+ {args} {


    Add common keywords to the project.



} {







    set d [ReadKeywords]
    dict lappend d config {*}$args

    WriteKeywords $d
    return
}

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

::kettle::special::Def keywords- {args} {


    Remove common keywords from the project.



} {







    set d [ReadKeywords]
    set k [dict get $d config]

    foreach remove $args {
	set pos [lsearch -exact $k $remove]
	if {$pos < 0} continue
	set k [lreplace $k $pos $pos]







<







 







<







 







|






|







 







|







 







>
>
>
>







 







>
>
>
>
>
>
>
|
>



|
>
>
>
|
<
>
>
>
>









|
>
>
>
|
>
>
>
|
<
>
|
<
<
<
>
|
>
>
>
>




>











|
>
>
>
>
>
>
>
>
>
>
>
>
>
>





|
>
>
>
|
<
>
>
>
>









|
>
>
|
<
>
>
>
>










|
>
>
|
>
>
>
>
|
<
>
>
|
>
>
>
>
>
>





>
>
>







 







|
>
>
|
<
>
>
>
>










|
>
>
|
>
>
>
>
|
>
>
>
>
>
>
>
>








|
>
>
|
>
>
>
|
>
>
>
>
>
>
>


>






|
>
>
|
>
>
>
|
>
>
>
>
>
>
>







20
21
22
23
24
25
26

27
28
29
30
31
32
33
..
54
55
56
57
58
59
60

61
62
63
64
65
66
67
...
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
...
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
...
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
...
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
...
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
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
}

# # ## ### ##### ######## ############# #####################
## API

kettle cli extend setup  {
    section {Project Management}

    description {
	Generate a basic build control file in the current working
	directory. The arguments, if any, name the API commands
	to put into the file. Defaults to 'tcl'.
    }
    input args {
	The DSL commands to place into the generated file.
................................................................................
    return
}

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

kettle cli extend {doc setup} {
    section {Project Management} Documentation

    description {
	Generates a basic documentation setup for the named
	project, in the current working directory. If the
	project is not named the last part of the directory
	name is used as default.

	Use 'doc configure', etc. to query and (re)configure
................................................................................
    DocConfigure \
	project   $pname \
	ptitle    $ptitle \
	copyright [clock format [clock seconds] -format %Y]

    meta get-vc-information [pwd] m
    if {[dict get $m vc::system] ne "unknown"} {
	DocConfigure vc_type [dict get $m vc::system]
    }

    # consolidate within meta, extend to git.
    if {[path find.fossil [pwd]] ne {}} {
	set remote [exec {*}[auto_execok fossil] remote]
	regsub {/[^@]*@} $remote {/} remote
	DocConfigure repository $remote
    }

    # 3. Place standard license (BSD).
    # 4. Place standard requirement (Tcl 8.5).
    # 5. Place standard requirement (Kettle build system).

    io puts ""
................................................................................

    io puts ""
    return
}

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

kettle cli extend {doc list-edit-hooks} {
    section {Project Management} Documentation

    description {
	Show all places in the generated documentation where the user
	can and should edit it to suit the project.
    }
} ::kettle::special::DocEditHooks
................................................................................
    }
    input args {
	The keys and values to set, or the key to query.
    } {
	optional ; list ; validate str
    }
} [lambda config {
    # TODO: For direct access filter out all the keys which are
    # handled by other commands (license, etc.) were using raw
    # configure can shoot ourselves in the foot.

    ::kettle::special::DocConfigure {*}[$config @args]
}]

proc ::kettle::special::DocConfigure {args} {
    variable cfgfile
    set theconfig [path norm $cfgfile]
    set data [Decode [path cat $theconfig]]
................................................................................
	     [dict merge \
		  [DecodeConfig [dict get $data config]] \
		  $args]]
    path write $theconfig [Encode $data vset]
    return
}

proc ::kettle::special::DocCGet {key} {
    variable cfgfile
    set theconfig [path norm $cfgfile]
    set data [Decode [path cat $theconfig]]

    # show specified key
    puts [dict get [DecodeConfig [dict get $data config]] $key]
    return
}

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

kettle cli extend {licenses} {
    section {Project Management} License

    description {
	List the available licenses we can apply to the project.

    }
} ::kettle::special::LicenseList

proc ::kettle::special::LicenseList {{config {}}} {
    foreach license [glob -directory [License] -tails *.inc] {
	set license [file rootname $license]
	io puts "  $license"
    }
    return
}

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

kettle cli extend {license set} {
    section {Project Management} License

    description {
	Set the license to use for the project.
    }
    input license {
	The name of the license chosen for the project.
    } {

	validate str ;#TODO: validate against available licenses
    }



} ::kettle::special::LicenseSet

proc ::kettle::special::LicenseSet {config} {
    variable docbase

    set name [$config @license]

    io puts ""
    io puts "Configuring license ..."

    # TODO: Move this into a custom validation type.
    set src [License ${name}.inc]
    set dst [path norm $docbase/parts/license.inc]

    if {![file exists $src]} {
	io err {
	    io puts "  No file found for license: $name"
	}
	return
    }

    PlacePart $src $dst
    DocConfigure license $name
    return
}

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

kettle cli extend {license show} {
    section {Project Management} License
    description {
	Show the license currently in use by the project.
    }
} ::kettle::special::LicenseShow

proc ::kettle::special::LicenseShow {config} {
    DocCGet license
    return
}

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

kettle cli extend {requirements available} {
    section {Project Management} Dependencies
    description {
	List the available text-blocks describing the requirements
	which can be apply to the project.

    }
} ::kettle::special::ReqAvailable

proc ::kettle::special::ReqAvailable {config} {
    foreach rq [lsort -dict [glob -directory [Require] -tails *.inc]] {
	set rq [file rootname $rq]
	io puts "  $rq"
    }
    return
}

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

kettle cli extend {requirements used} {
    section {Project Management} Dependencies
    description {
	List the requirements currently applied to the project.

    }
} ::kettle::special::ReqUsed

proc ::kettle::special::ReqUsed {config} {
    set d [ReadRequirements]
    dict with d {} ; # header, config
    foreach rq $config {
	puts \t$rq
    }
    return
}

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

kettle cli extend {requirements set} {
    section {Project Management} Dependencies
    description  {
	Set the requirements which apply to the project.
    }
    input args {
	The list of requirements to apply to the project,
	chosen from the available text-blocks.
    } {

	list
	validate str ;# TODO: validate against available blocks.
    }
} ::kettle::special::ReqSet

proc ::kettle::special::ReqSet {config} {
    set args [$config @args]

    variable docbase
    set d [ReadRequirements]
    dict set d config $args

    io puts ""
    io puts "Setting requirements ..."

    # TODO: Compare to the previous list of requirements and remove
    # the files for parts the user got rid of.

    foreach rq $args {
	set src [Require $rq.inc]
	set dst [path norm $docbase/parts/rq_${rq}.inc]

	if {![file exists $src]} {
	    io err {
................................................................................
    }
    WriteRequirements $d
    return
}

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

kettle cli extend {subjects} {
    section {Project Management} Subjects
    description  {
	List the common keywords currently applied to the project.

    }
} ::kettle::special::SubjList

proc ::kettle::special::SubjList {config} {
    set d [ReadKeywords]
    dict with d {} ; # header, config
    foreach kw [lsort -dict $config] {
	puts \t$kw
    }
    return
}

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

kettle cli extend {subject set} {
    section {Project Management} Subjects
    description {
	Set the keywords which apply to the project.
    }
    input args {
	The list of keywords to apply to the project.
	Can be empty.
    } {
	optional
	list
	validate str
    }
} ::kettle::special::SubjSet

proc ::kettle::special::SubjSet {config} {
    set args [$config @args]
    set d [ReadKeywords]
    dict set d config $args
    WriteKeywords $d
    return
}

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

kettle cli extend {subject add} {
    section {Project Management} Subjects
    description {
	Add keywords to the project.
    }
    input args {
	The list of keywords to add to the project.
    } {
	list
	validate str
    }
} ::kettle::special::SubjAdd

proc ::kettle::special::SubjAdd {config} {
    set args [$config @args]
    set d [ReadKeywords]
    dict lappend d config {*}$args
    # TODO: Handle duplicates, i.e. remove such.
    WriteKeywords $d
    return
}

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

kettle cli extend {subject remove} {
    section {Project Management} Subjects
    description {
	Remove keywords from the project.
    }
    input args {
	The list of keywords to remove from the project.
    } {
	list
	validate str
    }
} ::kettle::special::SubjRemove

proc ::kettle::special::SubjRemove {config} {
    set args [$config @args]
    set d [ReadKeywords]
    set k [dict get $d config]

    foreach remove $args {
	set pos [lsearch -exact $k $remove]
	if {$pos < 0} continue
	set k [lreplace $k $pos $pos]