Skip to content

Commit

Permalink
Remove builder/compiler support from opal command
Browse files Browse the repository at this point in the history
The opal command just duplicated all the Builder and BuilderTask
features so this commit reduces the opal command to be purely for
compiling a single file (or stdin) and printing back to stdout.
  • Loading branch information
Adam Beynon committed May 19, 2012
1 parent e9fdf34 commit b38f7bb
Showing 1 changed file with 8 additions and 36 deletions.
44 changes: 8 additions & 36 deletions bin/opal
Original file line number Diff line number Diff line change
@@ -1,43 +1,15 @@
#! /usr/bin/env ruby

require 'optparse'
require 'opal'

options = {}

OptionParser.new do |opts|
opts.on('-c', '--compile', 'Compile ruby') do
options[:compile] = true
end

opts.on('-o', '--out FILE', 'Output file') do |o|
options[:out] = o
end

opts.on('-p', '--print', 'Print result') do
options[:print] = true
end

opts.on_tail("-v", "--version", "Show version") do
puts Opal::VERSION
exit
end
end.parse! rescue abort("See `opal --help' for usage information.")

if options[:compile]
puts "No sources given" if ARGV.empty?

ARGV.each do |s|
puts "need to compile #{s}"
end

elsif options[:print]
puts "No sources given" if ARGV.empty?

ARGV.each do |s|
puts Opal.parse s
end
first = ARGV.first

if first.nil?
puts "Usage: opal path/to/file.rb"
elsif first == '-v' or first == '--version'
puts Opal::VERSION
elsif File.exist? first
puts Opal.parse File.read(first)
else
puts "No sources given"
puts Opal.parse(first)
end

0 comments on commit b38f7bb

Please sign in to comment.