Module: Clier
- Defined in:
- lib/clier.rb,
lib/clier/version.rb
Constant Summary collapse
- VERSION =
"1.0.3.1"
Class Method Summary collapse
Class Method Details
.parse(argv) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/clier.rb', line 5 def self.parse argv parsed = {} last_key = :key argv.each do |arg| case arg when /--?(.+)/ # -h, -a, -b, -9, --help, --action, --beta # get the first letter of (.+) e.g. -h => h, --help => h last_key = Regexp.last_match[1][0].to_sym parsed[last_key] = true when /(.+)/ # value parsed[last_key] = Regexp.last_match[1] # replace true => value end end parsed[:key] = parsed[:key].to_s if parsed[:key] parsed end |