lib/sickle.rb in sickle-0.3.0 vs lib/sickle.rb in sickle-0.4.0
- old
+ new
@@ -64,11 +64,11 @@
attr_accessor :name, :opts, :default
def initialize(name, opts)
@name, @opts = name, opts
- @default = opts.has_key?(:default) ? opts[:default] : false
+ @default = opts.has_key?(:default) ? opts[:default] : nil
if @default == true || @default == false
@type = :boolean
else
@type = @default.class.to_s.downcase.to_sym
@@ -196,11 +196,19 @@
def global_option(name, opts = {})
__global_options[name.to_s] = Option.new(name, opts)
end
+ def global_flag(name)
+ global_option(name, :default => false)
+ end
+
def option(name, opts = {})
Sickle.push_option(name, opts)
+ end
+
+ def flag(name)
+ option(name, :default => false)
end
def include_modules(hash)
hash.each do |key, value|
Sickle.push_namespace(key)