Method: Executable::Parser#parse_flags
- Defined in:
- lib/executable/parser.rb
#parse_flags(obj, opt, argv, args) ⇒ Object
Parse single-dash command-line option.
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 |
# File 'lib/executable/parser.rb', line 150 def parse_flags(obj, opt, argv, args) x = opt[1..-1] c = 0 x.split(//).each do |k| if obj.respond_to?("#{k}=") m = obj.method("#{k}=") if obj.respond_to?("#{x}?") m.call(true) else invoke(obj, m, argv) #m.call(argv.shift) end elsif obj.respond_to?("#{k}!") invoke(obj, "#{k}!", argv) else long = find_long_option(obj, k) if long if long.end_with?('=') && obj.respond_to?(long.chomp('=')+'?') invoke(obj, long, [true]) else invoke(obj, long, argv) end else obj.__send__(:option_missing, x, argv) end end end end |