#!/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