def initialize(*args)
name = args.dup
if name.last.is_a? Hash
attr = name.pop
else
attr = {}
end
raise "no option name: #{args.inspect}" if name.empty?
argument = nil
@usage_name = name
@name = name.to_a.map do |n|
unless n =~ /\A([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9_-]+)(\[?=.*)?\z/
raise "invalid option name: #{n.inspect}"
end
n = $1
argument = $2.nil? ? nil : $2 =~ /\A\[/ ? :optional : true
n
end
@argument = attr.key?(:argument) ? attr[:argument] : argument
@format = attr.key?(:format) ? attr[:format] : @argument ? true : nil
@default = attr[:default]
@description = attr[:description]
@multiple = attr.key?(:multiple) ? attr[:multiple] : :last
@completion = attr.key?(:completion) ? attr[:completion] : true
@underscore_is_hyphen = attr[:underscore_is_hyphen]
@in_config = attr.key?(:in_config) ? attr[:in_config] : true
@proc = attr[:proc]
@pre_proc = attr[:pre_proc]
@value = @default
@ovalue = @default
end