Browse Source

G-087 hygiene: fix punk.templates no-handler and registration error paths

- put -> puts at all six no-handler warning sites (commandset layout x2,
  project, module, scriptwrap, mix/base get_template_basefolders - the sweep
  found three sites beyond the review's list). Three procs also dereferenced
  an unset result variable after the warning; the no-handler paths now warn
  and return an empty dict. layout references_as_dict and module templates_dict
  warning messages no longer misattribute their owning proc.
- punk::cap::handlers::templates: brace the absolute-pathtype existence test
  ('if {!file exists $normpath}' raised an expr syntax error on any
  absolute-pathtype provider registration), and add the missing dict-exists
  check in pkg_register's duplicate-registration guard (errored 'key not known
  in dictionary' for any second provider package registering a capability).
- Versions: commandset layout 0.1.1, project 0.2.2, module 0.1.1,
  scriptwrap 0.1.1, cap handlers templates 0.1.1; punk::mix::base 0.1 -> 0.1.1
  (manually versioned: file renamed, provide block updated, history comment
  added).

Verified: scratch no-handler/registration checks 13/13 (see
goals/G-087-thin-project-layouts.md Progress); runtests prune/fossilmove/
multishell/libsearch all pass; make.tcl modules builds clean.

Assisted-by: harness=claude; primary-model=claude-fable-5; api-location=anthropic.com
master
Julian Noble 6 days ago
parent
commit
290f427ae9
  1. 4
      src/modules/punk/cap/handlers/templates-999999.0a1.0.tm
  2. 4
      src/modules/punk/cap/handlers/templates-buildversion.txt
  3. 7
      src/modules/punk/mix/base-0.1.1.tm
  4. 10
      src/modules/punk/mix/commandset/layout-999999.0a1.0.tm
  5. 3
      src/modules/punk/mix/commandset/layout-buildversion.txt
  6. 3
      src/modules/punk/mix/commandset/module-999999.0a1.0.tm
  7. 3
      src/modules/punk/mix/commandset/module-buildversion.txt
  8. 2
      src/modules/punk/mix/commandset/project-999999.0a1.0.tm
  9. 3
      src/modules/punk/mix/commandset/project-buildversion.txt
  10. 2
      src/modules/punk/mix/commandset/scriptwrap-999999.0a1.0.tm
  11. 3
      src/modules/punk/mix/commandset/scriptwrap-buildversion.txt

4
src/modules/punk/cap/handlers/templates-999999.0a1.0.tm

@ -172,7 +172,7 @@ namespace eval punk::cap::handlers::templates {
return 0
}
set normpath [file normalize $path]
if {!file exists $normpath} {
if {![file exists $normpath]} {
puts stderr "punk::cap::handlers::templates::capsystem::pkg_register WARNING - package '$pkg' is attempting to register with punk::cap as a provider of '$capname' capability but provided a path '$path' which doesn't seem to exist"
return 0
}
@ -197,7 +197,7 @@ namespace eval punk::cap::handlers::templates {
if {$capname ni $::punk::cap::handlers::templates::handled_caps} {
lappend ::punk::cap::handlers::templates::handled_caps $capname
}
if {![info exists provider_info] || $extended_capdict ni [dict get $provider_info $pkg]} {
if {![info exists provider_info] || ![dict exists $provider_info $pkg] || $extended_capdict ni [dict get $provider_info $pkg]} {
#this checks for duplicates from the same provider - but not if other providers already added the path
#review -
dict lappend provider_info $pkg $extended_capdict

4
src/modules/punk/cap/handlers/templates-buildversion.txt

@ -1,3 +1,5 @@
0.1.0
0.1.1
#First line must be a semantic version number
#all other lines are ignored.
#0.1.1 - fix: pkg_register 'absolute' pathtype branch had a non-braced expr 'if {!file exists $normpath}' which raised an expr syntax error on any absolute-pathtype provider registration; now correctly tests ![file exists $normpath]
#0.1.1 - fix: pkg_register duplicate-registration guard did 'dict get $provider_info $pkg' without a dict exists check, erroring for any second provider package registering the same capability

7
src/modules/punk/mix/base-0.1.tm → src/modules/punk/mix/base-0.1.1.tm

@ -1,7 +1,9 @@
package provide punk::mix::base [namespace eval punk::mix::base {
variable version
set version 0.1
set version 0.1.1
}]
#version history (manually versioned module - real version is the filename/provide value)
#0.1.1 - fix: get_template_basefolders no-handler warning used 'put' instead of 'puts'; missing-handler path now warns and returns an empty dict instead of erroring on an unset variable
package require punk::path
package require punk::lib ;#format_number etc
@ -393,7 +395,8 @@ namespace eval punk::mix::base {
if {[punk::cap::capability_has_handler punk.templates]} {
set template_folder_dict [punk::cap::call_handler punk.templates folders -startdir $startpath]
} else {
put stderr "get_template_basefolders WARNING - no handler available for the 'punk.templates' capability - template providers will be unable to provide template locations"
puts stderr "get_template_basefolders WARNING - no handler available for the 'punk.templates' capability - template providers will be unable to provide template locations"
set template_folder_dict [dict create]
}
#don't sort - order in which encountered defines the precedence - with later overriding earlier

10
src/modules/punk/mix/commandset/layout-999999.0a1.0.tm

@ -205,10 +205,11 @@ namespace eval punk::mix::commandset::layout {
if {[punk::cap::capability_has_handler punk.templates]} {
set ref_dict [punk::cap::call_handler punk.templates get_itemdict_projectlayoutrefs {*}$args]
} else {
put stderr "commandset::layout::lib::layouts_dict WARNING - no handler available for the 'punk.templates' capability - template providers will be unable to provide template locations"
puts stderr "commandset::layout::collection::references_as_dict WARNING - no handler available for the 'punk.templates' capability - template providers will be unable to provide template locations"
set ref_dict [dict create]
}
return $ref_dict
}
}
}
namespace eval lib {
proc layouts_dict {args} {
@ -216,10 +217,11 @@ namespace eval punk::mix::commandset::layout {
if {[punk::cap::capability_has_handler punk.templates]} {
set layout_dict [punk::cap::call_handler punk.templates get_itemdict_projectlayouts {*}$args]
} else {
put stderr "commandset::layout::lib::layouts_dict WARNING - no handler available for the 'punk.templates' capability - template providers will be unable to provide template locations"
puts stderr "commandset::layout::lib::layouts_dict WARNING - no handler available for the 'punk.templates' capability - template providers will be unable to provide template locations"
set layout_dict [dict create]
}
return $layout_dict
}
}
proc layout_all_files {layout} {
#todo - allow versionless layout name to pick highest version found

3
src/modules/punk/mix/commandset/layout-buildversion.txt

@ -1,3 +1,4 @@
0.1.0
0.1.1
#First line must be a semantic version number
#all other lines are ignored.
#0.1.1 - fix: no-handler warning paths in collection::references_as_dict and lib::layouts_dict used 'put' instead of 'puts' and then errored on an unset dict variable; they now warn correctly and return an empty dict. references_as_dict warning message no longer misattributes itself to layouts_dict.

3
src/modules/punk/mix/commandset/module-999999.0a1.0.tm

@ -137,7 +137,8 @@ namespace eval punk::mix::commandset::module {
if {[punk::cap::capability_has_handler punk.templates]} {
set template_folder_dict [punk::cap::call_handler punk.templates get_itemdict_moduletemplates {*}$args]
} else {
put stderr "get_template_basefolders WARNING - no handler available for the 'punk.templates' capability - template providers will be unable to provide template locations"
puts stderr "commandset::module::templates_dict WARNING - no handler available for the 'punk.templates' capability - template providers will be unable to provide template locations"
set template_folder_dict [dict create]
}
}

3
src/modules/punk/mix/commandset/module-buildversion.txt

@ -1,3 +1,4 @@
0.1.0
0.1.1
#First line must be a semantic version number
#all other lines are ignored.
#0.1.1 - fix: templates_dict no-handler warning path used 'put' instead of 'puts' and left the result variable unset; now warns correctly (attributed to templates_dict rather than get_template_basefolders) and returns an empty dict

2
src/modules/punk/mix/commandset/project-999999.0a1.0.tm

@ -252,7 +252,7 @@ namespace eval punk::mix::commandset::project {
if {[punk::cap::capability_has_handler punk.templates]} {
set layout_dict [punk::cap::call_handler punk.templates get_itemdict_projectlayouts]
} else {
put stderr "commandset::project::new WARNING - no handler available for the 'punk.templates' capability - template providers will be unable to provide layout locations"
puts stderr "commandset::project::new WARNING - no handler available for the 'punk.templates' capability - template providers will be unable to provide layout locations"
return
}
if {[dict exists $layout_dict $opt_layout]} {

3
src/modules/punk/mix/commandset/project-buildversion.txt

@ -1,6 +1,7 @@
0.2.1
0.2.2
#First line must be a semantic version number
#all other lines are ignored.
#0.2.2 - fix: new's no-handler warning path used 'put' instead of 'puts' (raised invalid command name error instead of warning)
#0.2.1 - fix: -layout now validated and normalized via tcl::prefix::match against documented layout choices, matching the PUNKARGS -choiceprefix default (true); previously the manual parser accepted arbitrary values with no validation
#0.2.0 - updated punkcheck::install call sites to use -exclude-paths / -exclude-paths-core (replaced -antiglob-paths + -exclude-dirsegments) — call-site API change warrants minor bump
#0.2.0 - updated call sites to use hyphenated flag names (-punkcheck-folder, -exclude-paths-core)

2
src/modules/punk/mix/commandset/scriptwrap-999999.0a1.0.tm

@ -141,7 +141,7 @@ namespace eval punk::mix::commandset::scriptwrap {
if {[punk::cap::capability_has_handler punk.templates]} {
return [punk::cap::call_handler punk.templates get_itemdict_scriptappwrappers {*}$args]
} else {
put stderr "commandset::scriptwrap::templates_dict WARNING - no handler available for the 'punk.templates' capability - template providers will be unable to provide template locations"
puts stderr "commandset::scriptwrap::templates_dict WARNING - no handler available for the 'punk.templates' capability - template providers will be unable to provide template locations"
}
return
}

3
src/modules/punk/mix/commandset/scriptwrap-buildversion.txt

@ -1,3 +1,4 @@
0.1.0
0.1.1
#First line must be a semantic version number
#all other lines are ignored.
#0.1.1 - fix: templates_dict no-handler warning path used 'put' instead of 'puts' (raised invalid command name error instead of warning)

Loading…
Cancel
Save