Module: Wahy::Opt_PARSER

Defined in:
lib/wahy.rb

Class Method Summary collapse

Class Method Details

.opsiyonlar(opts) ⇒ Object



12982
12983
12984
12985
12986
12987
12988
12989
12990
12991
12992
12993
12994
12995
12996
12997
12998
12999
13000
13001
13002
13003
13004
13005
13006
13007
13008
13009
13010
13011
13012
13013
13014
13015
13016
13017
13018
# File 'lib/wahy.rb', line 12982

def self.opsiyonlar opts
  options = {}
  parser = OptionParser.new do |o|
    o.banner = "Usage: wahy [options]"


    o.on("-lLANG", "--lang=LANGUAGE", "Which language that you want to read signs?") do |l|
      options[:lang] = l
    end

    o.on("-sSCRIPTURE", "--scripture=SCRIPTURE", "Scripture name or number") do |s|
      if s =~ /[[:digit:]]/
        options[:scripture] = s.to_i - 1
      elsif s == 'all'
        options[:scripture] = s
      else
        scr = s.include?(" ") ? s.split(" ").map {|i| i = i.capitalize}.join(" ") : s.capitalize
        SURELER.values.each do |v|
          options[:scripture] = v.index(scr) if v.include? scr
        end
      end
    end

    o.on("-asign", "--ayah=SIGN", "Sign number") do |a|
      a = a.to_i - 1 unless a == 'all'
      options[:sign] = a
    end

    o.on("-h", "--help", "Prints this help") do
      puts o
      exit
    end
  end

  parser.parse!(opts)
  options
end