mikbe/commandable — Issue #7: Add example for global parameters.
Author: mikbe
Created: 2012-01-12 16:05:20+00:00
State: open

Add an explanation and example for setting and using global parameters:

require 'commandable'

class Foo
extend Commandable

command "Do the bar"
def bar
puts "Foo#Bar called. Qiz set: #{Settings.qiz || false}"
end

end

class Settings
extend Commandable

def self.qiz
@@qiz ||= false
end

command "set qiz", priority: 1
def qiz
@@qiz = true
end

end

Commandable.execute(ARGV)