#!/usr/bin/env ruby require 'glueckskeks' require 'optparse' options = {corpus: 'corpus', base: 'base', capitalize: true} optparse = OptionParser.new do |opts| opts.banner = "Usage: #{$PROGRAM_NAME}" opts.separator "" opts.separator "Generate phrase from files (default: in corpus/)." opts.separator "" opts.on('-b', '--base=BASE', 'Start extension from BASE file (default: \'base\')') do |b| options[:base] = b end opts.on('-c', '--corpus=DIRECTORY', 'Read .corpus files from DIRECTORY (default: \'./corpus\')') do |c| options[:corpus] = c end opts.on('-d', '--debug', 'Print debug messages to STDOUT') do |d| options[:debug] = d end opts.on('--[no-]capitalize', 'Capitalize first letter of output (default: true)') do |c| options[:capitalize] = c end opts.on_tail('--version', 'Show version and exit.') do puts "#{$PROGRAM_NAME} #{Glueckskeks::VERSION}" exit 0 end opts.on('-h', '--help', 'Show this help and exit.') do puts opts exit 0 end end.parse! Glueckskeks.logger.level = options[:debug] ? Logger::DEBUG : Logger::INFO phrase = Glueckskeks.generate(options[:corpus], options[:base]) if options[:capitalize] phrase = phrase[0].upcase + phrase[1..-1] end puts phrase puts Glueckskeks::Collapser.collapse(phrase) # Leave the stage with grace. exit 0