aboutsummaryrefslogtreecommitdiff
path: root/nshelper.tcl
diff options
context:
space:
mode:
authorSteve Bennett <steveb@workware.net.au>2011-12-01 14:32:09 +1000
committerSteve Bennett <steveb@workware.net.au>2023-02-13 10:52:21 +1000
commit4255d54c254a5f49a19017a3071b8d7ff35e70e9 (patch)
tree3f0a7d263850cb461321d76b6ca5f84a286f7322 /nshelper.tcl
parentd295fb1b6124575793add4b95860fabd1539a099 (diff)
downloadjimtcl-4255d54c254a5f49a19017a3071b8d7ff35e70e9.zip
jimtcl-4255d54c254a5f49a19017a3071b8d7ff35e70e9.tar.gz
jimtcl-4255d54c254a5f49a19017a3071b8d7ff35e70e9.tar.bz2
ensemble: Add a simple ensemble command
Uses a prefix to automatically map from subcommand to implementation. Includes support for namespace ensemble Signed-off-by: Steve Bennett <steveb@workware.net.au>
Diffstat (limited to 'nshelper.tcl')
-rw-r--r--nshelper.tcl14
1 files changed, 14 insertions, 0 deletions
diff --git a/nshelper.tcl b/nshelper.tcl
index 9e617b7..499022e 100644
--- a/nshelper.tcl
+++ b/nshelper.tcl
@@ -143,3 +143,17 @@ proc {namespace upvar} {ns args} {
}
tailcall {*}$script
}
+
+proc {namespace ensemble} {subcommand args} {
+ if {$subcommand ne "create"} {
+ return -code error "only \[namespace ensemble create\] is supported"
+ }
+ set ns [uplevel 1 namespace canon]
+ set cmd $ns
+ if {$ns eq ""} {
+ return -code error "namespace ensemble create: must be called within a namespace"
+ }
+
+ # Create the mapping
+ ensemble $cmd -automap ${ns}:: {*}$args
+}