koraktor / rubikon

A simple to use, yet powerful Ruby framework for building console-based applications.
http://koraktor.github.com/rubikon
BSD 3-Clause "New" or "Revised" License
93 stars 2 forks source link

Allow command chaining #10

Closed koraktor closed 13 years ago

koraktor commented 13 years ago

Implement a simple DSL method to call a command from inside another command's code.

command :inner, [:arg] do
  @inner = arg
end

command :outer do
  call :inner, 'test'
  # @inner should be 'test' here
end
CarterA commented 13 years ago

I needed to do this, so I just used the following:

@commands[:inner].run

Works perfectly, though a DSL method would probably make more sense.

koraktor commented 13 years ago

This workaround won't work in version 0.4.0 though. You'll need something more complex due to application sandboxing.

@__app__.instance_eval { @commands[:inner].run }

Another reason why I want to implement this.

koraktor commented 13 years ago

Added DSL method 'call' to delegate other commands

Closed by da5822bd41287d39e9804c4bf0bb7c7fde665534