Sha256: 49b24fdce500ba29cc857a861b6b2e57bb6f64ab0e6640ab7736592a5c51ee33

Contents?: true

Size: 826 Bytes

Versions: 2

Compression:

Stored size: 826 Bytes

Contents

#!/usr/bin/env ruby

require "optparse"
require "guillaume"

options = {}
option_parser = OptionParser.new do |opts|
  opts.banner = "Usage: guillaume /path/to/text_source.txt"

  opts.on("-v", "--verbose", "Verbose output while writing") do
    $LOGGER.level = Logger::INFO
  end

  options[:max_stanzas] = 10
  opts.on("-m", "--max-stanzas STANZAS", Integer, "Maximum number of stanzas to write") do |m|
    options[:max_stanzas] = m
  end
end

option_parser.parse!

source_text_file = ARGV.pop

if !source_text_file && options.empty?
  puts option_parser.help
  exit
end

# required
unless source_text_file
  raise ArgumentError, "Please point to a source text file"
end

# validations

poem = Guillaume::Poem.new(Guillaume::SourceText.new(source_text_file), max_stanzas: options[:max_stanzas])
puts ""
puts poem.formatted

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
guillaume-0.0.2 bin/guillaume
guillaume-0.0.1 bin/guillaume