Sha256: 538c703f8ea6617d1917bdb605981c7ad814c55e8fcf413cf68dfc89472b94c9

Contents?: true

Size: 916 Bytes

Versions: 6

Compression:

Stored size: 916 Bytes

Contents

#!/usr/bin/env ruby

lib = File.expand_path(File.dirname(__FILE__) + '/../lib')
$LOAD_PATH.unshift(lib) if File.directory?(lib) && !$LOAD_PATH.include?(lib)

require 'optparse'
require_relative '../lib/typogrowth'

options = {}
OptionParser.new do |opts|
  opts.banner = "Usage: #{$0} FILE|STRING"

  # Bowl result?
  opts.on("-o", "--out FILE",
          "Output file name for result") do |outfile|
    options[:outfile] = outfile
  end

  # No argument, shows at tail.  This will print an options summary.
  opts.on_tail("-h", "--help", "Show this message") do
    puts opts
    exit
  end
end.parse!

raise "Run `#{$0} --help` for execution examples. Exiting…" if ARGV.size.zero?

file_or_string = ARGV.first
file_or_string = File.read(file_or_string) if File.exist?(file_or_string)

@result = Typogrowth::parse file_or_string

options[:outfile].nil? ?
  puts(@result) :
  File.write(options[:outfile], @result)

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
typogrowth-0.9.8 bin/typo
typogrowth-0.9.7 bin/typo
typogrowth-0.9.5 bin/typo
typogrowth-0.9.3 bin/typo
typogrowth-0.9.1 bin/typo
typogrowth-0.9.0 bin/typo