#!/usr/bin/env ruby # encoding: utf-8 require 'optparse' require 'pp' $:.push File.expand_path("../../lib", __FILE__) require 'jumping_words' options = {} optparse = OptionParser.new do|opts| #The command addes a word opts.on( '-a', '--add', 'Add the word' ) do if ARGV.empty? or ARGV.size < 2 puts 'You mast set 2 words! Firs is word, second is translate. Like this: "./word -a to run: бежать"' exit else db = DbWords.new(ARGV) db.add exit end end #The command deletes a word opts.on( '-d', '--destroy', 'Delete the word' ) do if ARGV.empty? puts 'You mast set number of word!' exit else db = DbWords.new(ARGV) db.destroy exit end end #The list of words opts.on( '-l', '--list', 'List of words' ) do db = DbWords.new db.list exit end #run the application opts.on( '-s', '--start', 'Start of app' ) do db = DbWords.new app = SayWords.new(db.collection, :show_message => SHOW_MESSAGE, :space_words => SPACE_WORDS, :space_interation => SPACE_INTERATION) begin app.run rescue Interrupt puts "Exiting..." end end end optparse.parse!