Sha256: 8349e57eae06f0aff7179e89eb93b52257ac0c22948dcc7acf215d38a85eeef3

Contents?: true

Size: 968 Bytes

Versions: 3

Compression:

Stored size: 968 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/qipowl'

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

  # Bowl result?
  opts.on("-a", "--action ACTION", [:bowl, :ruby, :cmd, :yaml, :html],
          "Action to apply on input (bowl, html); default: html") do |action|
    options[:action] = action || :bowl
  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)

case options[:action]
when :bowl
  puts file_or_string.bowl
else
  puts Qipowl::Html.parse file_or_string
end  

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
qipowl-0.9.3 bin/bowler
qipowl-0.9.2 bin/bowler
qipowl-0.9.1 bin/bowler