#!/usr/bin/env ruby $LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../lib") require 'xibtoti' require 'optparse' OptionParser.new do |opts| opts.banner = "Usage: xibtoti [options] filename" opts.on("-w", "--[no-]warnings", "Show warnings") do |w| @show_warnings = w end opts.on("-o", "--output-file name", "Specify output file") do |o| @output_file = o end opts.on("-c", "--config-file name", "Specify config file") do |o| @config_file = o end end.parse! if ARGV.size == 1 input_file = ARGV.first session = Session.new @config_file || File.join("#{File.dirname(__FILE__)}/../lib", 'config.rb') session.parse_file input_file if session.has_errors? puts "Aborted!" puts session.full_log [:error] else severities = [] severities.unshift :warning if @show_warnings log = session.full_log severities script = js_comments_for(log) + js_for(session.out) if @output_file File.open(@output_file, 'w') do |file| file.write script end puts log else puts script end end else puts "For help, type: xibtoti -h" end