Sha256: 1bb87d9d3d4bf2fa04892c0bd644feb23008be16cb055dc45134acceb11b343e
Contents?: true
Size: 1.19 KB
Versions: 1
Compression:
Stored size: 1.19 KB
Contents
module Hieracles class Optparse attr_reader :options, :payload OPTIONS = { config: { has_arg: true, aliases: ['c', 'conf', 'config'] }, format: { has_arg: true, aliases: ['f', 'format'] }, params: { has_arg: true, aliases: ['p', 'params'] }, hierafile: { has_arg: true, aliases: ['h', 'hierafile'] }, basepath: { has_arg: true, aliases: ['b', 'basepath'] }, encpath: { has_arg: true, aliases: ['e', 'encpath'] }, version: { has_arg: false, aliases: ['v', 'version'] } } def initialize(array) @options = {} @payload = [] ok = optionkeys while x = array.shift if x[0] == '-' if ok[x[/[a-z][-_a-z]*$/]] @options[ok[x[/[a-z][-_a-z]*$/]]] = array.shift else array.shift end else @payload << x end end end def optionkeys back = {} OPTIONS.each do |k, v| v[:aliases].each do |a| back[a] = k end end back end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
hieracles-0.1.0 | lib/hieracles/optparse.rb |