Sha256: 98c2d85aab92e24623ad60eac7215fcf25ab8c29d40b69cd28b6927b6b2dd827

Contents?: true

Size: 1.92 KB

Versions: 85

Compression:

Stored size: 1.92 KB

Contents

#!/usr/bin/env ruby

require 'optparse'

module Opal
  class BuilderOptions < OptionParser
    def initialize
      @options = {}

      super do |opts|
        opts.banner = 'Usage: opal-build [options] -- [libname]'

        opts.separator ''
        opts.separator 'Options:'

        opts.on("-h", "--help", "Show this message") do
          puts opts
          exit
        end

        opts.on('-g', '--gem GEM_NAME', String,
                'Adds the specified GEM_NAME lib dir to Opal\'s load path.',
                'E.g.: opal-build --gem erubis -- erubis`',
                'Will build erubis.rb from the regular "erubis" gem') do |g|
          options[:gems] ||= []
          options[:gems] << g
        end

        opts.on('-s', '--stub STUB', String) do |stub|
          options[:stubs] ||= []
          options[:stubs] << stub
        end

        opts.on('-r', '--require LIBRARY', String,
                'Require the library before executing your script',
                'E.g.: opal-build --require opal-browser browser`',
                'Will build browser.rb from the Opal gem opal-browser') do |library|
          options[:requires] ||= []
          options[:requires] << library
        end

        opts.on('-o', '--output FILE', String,
                'Write the built lib to a file (defaults to STDOUT)') do |file|
          options[:output] = file
        end
      end
    end

    attr_reader :options
  end
end

option_parser = Opal::BuilderOptions.new
option_parser.parse!

if ARGV.empty?
  puts option_parser
else
  require 'opal'
  options = option_parser.options

  if options[:gems]
    require 'rubygems'
    options[:gems].each { |gem_name| Opal.use_gem gem_name }
  end

  if options[:requires]
    options[:requires].each { |required_lib| require required_lib }
  end

  lib_name = ARGV.first

  output = options[:output] ? File.open(options[:output], 'w') : $stdout
  output.puts Opal::Builder.build(lib_name.dup.untaint)
end


Version data entries

85 entries across 85 versions & 3 rubygems

Version Path
opal-1.8.2 exe/opal-build
opal-1.8.1 exe/opal-build
opal-1.8.0 exe/opal-build
opal-1.8.0.beta1 exe/opal-build
opal-1.7.4 exe/opal-build
opal-1.8.0.alpha1 exe/opal-build
opal-1.7.3 exe/opal-build
opal-1.7.2 exe/opal-build
opal-1.7.1 exe/opal-build
opal-1.7.0 exe/opal-build
opal-1.7.0.rc1 exe/opal-build
opal-1.6.1 exe/opal-build
opal-1.6.0 exe/opal-build
opal-1.6.0.rc1 exe/opal-build
opal-1.6.0.alpha1 exe/opal-build
opal-1.5.1 exe/opal-build
opal-1.5.0 exe/opal-build
opal-1.5.0.rc1 exe/opal-build
opal-1.4.1 exe/opal-build
opal-1.4.0 exe/opal-build