Sha256: 8277cfd5f1be87f9e07f7b7745c5f118e0478d5171cdad1794d5f8d0615a0a5d

Contents?: true

Size: 1.19 KB

Versions: 1

Compression:

Stored size: 1.19 KB

Contents

#!/usr/bin/env ruby
require 'gli'
require 'hemlock'
require 'readline'
require 'rainbow'

include GLI::App

program_desc 'Memorization through repetitive writing - Socrates is not amused'

version Hemlock::VERSION

pre do |global,command,options,args|
  true
end

command :drink do |c|
  c.desc "Crito, we owe a rooster to Asclepius. Please, don't forget to pay the debt."

  c.action do
    flashcards = Hemlock::CSVtoFlashcards.create_flashcards
    5.times do
      seed = rand(0..(flashcards.length - 1))
      flashcard = flashcards[seed]
      puts flashcard.question
      answer = Readline.readline('>> ', false)
      if answer == flashcard.answer
        puts printf Rainbow('Correct').green
      else
        puts printf Rainbow('You must submit to the quarries').red
        3.times do
          puts flashcard.question
          puts flashcard.answer
          answer = Readline.readline('>> ', false)
        end
      end
    end
  end
end

post do |global,command,options,args|
  # Post logic here
  # Use skips_post before a command to skip this
  # block on that command only
end

on_error do |exception|
  # Error logic here
  # return false to skip default error handling
  true
end

exit run(ARGV)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hemlock-0.0.3 bin/hemlock