# ACTIVESTATE TEAPOT-PKG BEGIN TM -*- tcl -*- # -- Tcl Module # @@ Meta Begin # Package cmdr 0.7 # Meta author {Andreas Kupries} # Meta build::by andreask # Meta build::date 2013-10-27 # Meta description A framework for the specification and use of complex # Meta description command line processing. # Meta location https://core.tcl.tk/akupries/cmdr # Meta platform tcl # Meta require TclOO # Meta require cmdr::officer # Meta require debug # Meta require debug::caller # Meta require {Tcl 8.5-} # Meta subject {command line} delegation dispatch options arguments # Meta summary Main entry point to the commander framework. # Meta vc::revision 3ffaa05e81b0a689b14ffd07487583700e03dcf2 # Meta vc::system fossil # @@ Meta End # ACTIVESTATE TEAPOT-PKG BEGIN REQUIREMENTS package require TclOO package require cmdr::officer package require debug package require debug::caller package require Tcl 8.5- # ACTIVESTATE TEAPOT-PKG END REQUIREMENTS # ACTIVESTATE TEAPOT-PKG BEGIN DECLARE package provide cmdr 0.7 # ACTIVESTATE TEAPOT-PKG END DECLARE # ACTIVESTATE TEAPOT-PKG END TM ## -*- tcl -*- # # ## ### ##### ######## ############# ##################### ## Command dispatcher framework. ## Knows about officers and privates. ## Encapsulates the creation of command hierachies. # @@ Meta Begin # Package cmdr 0 # Meta author {Andreas Kupries} # Meta location https://core.tcl.tk/akupries/cmdr # Meta platform tcl # Meta summary Main entry point to the commander framework. # Meta description A framework for the specification and # Meta description use of complex command line processing. # Meta subject {command line} delegation dispatch options arguments # Meta require TclOO # Meta require cmdr::officer # Meta require debug # Meta require debug::caller # Meta require {Tcl 8.5-} # @@ Meta End # # ## ### ##### ######## ############# ##################### ## Requisites package require Tcl 8.5 package require debug package require debug::caller package require TclOO package require cmdr::officer # # ## ### ##### ######## ############# ##################### debug define cmdr/main debug level cmdr/main debug prefix cmdr/main {[debug caller] | } # # ## ### ##### ######## ############# ##################### ## Definition namespace eval ::cmdr { namespace export new create interactive interactive? namespace ensemble create # Generally interaction is possible. variable interactive 1 } # # ## ### ##### ######## ############# proc ::cmdr::new {name spec} { debug.cmdr/main {} return [cmdr::officer new {} $name $spec] } proc ::cmdr::create {obj name spec} { debug.cmdr/main {} # Uplevel to ensure proper namespace for the 'obj'. return [uplevel 1 [list cmdr::officer create $obj {} $name $spec]] } # # ## ### ##### ######## ############# ##################### ## Global interactivity configuration. proc ::cmdr::interactive {{enable 1}} { debug.cmdr/main {} variable interactive $enable return } proc ::cmdr::interactive? {} { variable interactive return $interactive } # # ## ### ##### ######## ############# ##################### ## Ready package provide cmdr 0.7