#!/usr/bin/env ruby require 'rubygems' require_relative '../lib/livetext' def handle_lt3(src) abort "Unknown file extension" unless src =~ /.lt3$/ end # Main x = Livetext.new @backtrace = false def usage puts <<-EOF Usage: livetext filename Read STDIN livetext -s livetext --stdin Show help: livetext livetext -h livetext --help Show path: livetext -p livetext --path Run tests: livetext -t livetext --test Show version: livetext -v livetext --version Turn on backtrace: livetext -b livetext --backtrace Install plugin: livetext -i filename.rb livetext -install filename.rb EOF puts exit end usage if ARGV.empty? loop do arg = ARGV.shift break if arg.nil? case arg when "-v", "--version" puts "#{Livetext::VERSION}\n " when "-t", "--test" file = "#{Livetext::Path}/../test/test.rb" flag = @backtrace ? "-back" : "" cmd = "ruby #{file} cmdline#{flag}" puts cmd system(cmd) when "-p", "--path" puts Livetext::Path when "-b", "--backtrace" @backtrace = true when "-s", "--stdin" src = STDIN.read x.process(src) when "-h", "--help" usage when "-i", "--install" lib = ARGV.shift system("cp #{lib} #{Livetext::Path}/../plugin/") when Object x.process_file(arg) # , @backtrace) end end puts x.body