class AlbaHabla::Cli

Class used to parse command line arguments

Constants

DEFAULT_OPTIONS

Public Class Methods

parse(args) click to toggle source

rubocop:disable Metrics/MethodLength

# File lib/alba_habla/cli.rb, line 11
def self.parse(args)
  options = DEFAULT_OPTIONS.dup

  opt_parser = OptionParser.new do |opts|
    opts.banner = 'Usage: alba_habla [options]'

    opts.on('-bBOOK_PATH', '--books=BOOK_PATH', 'Path to folder with book files') do |bp|
      options[:book_path] = bp.end_with?('/') ? bp : "#{bp}/"
    end

    opts.on('-vVOICE', '--voice=VOICE', 'Voice to be used by your speech synthesizer') do |v|
      options[:voice] = v
    end
  end

  opt_parser.parse!(args)
  options
end