forked from opal/opal
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove builder/compiler support from opal command
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.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |