From 4255d54c254a5f49a19017a3071b8d7ff35e70e9 Mon Sep 17 00:00:00 2001 From: Steve Bennett Date: Thu, 1 Dec 2011 14:32:09 +1000 Subject: 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 --- nshelper.tcl | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'nshelper.tcl') 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 +} -- cgit v1.1