Posted to tcl by Stu at Sun Nov 17 15:34:32 GMT 2019view raw

  1. namespace eval schema {
  2. namespace ensemble create
  3. namespace export command
  4. namespace eval command {
  5. namespace ensemble create
  6. namespace export mod1 mod2
  7. proc mod1 {args} { return "mod1: $args" }
  8. proc mod2 {args} { return "mod2: $args" }
  9. }
  10. }
  11. proc schema: {what args} { uplevel 1 [list schema {*}[string map {/ " "} $what] {*}$args] }
  12.  
  13. % schema: command/mod1 dog goes woof
  14. mod1: dog goes woof
  15. % schema: command/mod2
  16. mod2:
  17. % schema: command/mod3
  18. unknown or ambiguous subcommand "mod3": must be mod1, or mod2