I have a DSL in Ruby that works like so:
desc \'list all todos\' command :list do |c| c.desc \'show todos in long form\' c.switch :l c.action do |globa
I wrote a class that handles this exact issue, and deals with things like @instance_variable access, nesting, and so forth. Here's the write-up from another question:
Block call in Ruby on Rails