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 easier argument access in option blocks #4

Closed koraktor closed 13 years ago

koraktor commented 14 years ago

If you want to access the argument of a option, you still need to use the full "path" of the argument. A shortcut would be very handy:

option :user, 1 do
  @user = self[0] # instead of args[:user][0]
end

Or even better with named arguments (see issue #3):

option :user, [:name] do
  @user = self[:name]
end

This could be even further improved using e.g. Option#method_missing.

koraktor commented 13 years ago

This has been implemented in c471e5b07945b943fade6da7c6d07a7be98011b4.

The next step will be to allow argument access using simple methods (i.e. Option#method_missing).

option :user, [:name] do
  @user = name
end 
koraktor commented 13 years ago

e695ccf15ed315b391fe451cdf693ad414b0c4a3 and d1de7dac75edd83f052e64a5381a598ea6ee8aa6 implement even more simplified argument access.