Sha256: 667453828c60451f600c189c8cee2cded2581c0e6649c419c4eb5a83a697fbc9

Contents?: true

Size: 1.4 KB

Versions: 1

Compression:

Stored size: 1.4 KB

Contents

#!/usr/bin/env ruby
#
#  Created by Darren Boyd on 2007-9-24.
#  Copyright (c) 2007. All rights reserved.

begin
  require 'rubygems'
rescue LoadError
  # no rubygems to load, so we fail silently
end

require 'optparse'

# NOTE: the option -p/--path= is given as an example, and should probably be replaced in your application.

OPTIONS = {
}
MANDATORY_OPTIONS = %w(  )

parser = OptionParser.new do |opts|
  begin
    opts.banner = <<BANNER_END
Usage: #{File.basename($0)} [options] <file> [<file> ...]

Options are:
BANNER_END
    opts.on("-c", "--console", "Run in console mode.") {OPTIONS[:console] = true}

    opts.on("-h", "--help",
            "Show this help message.") { puts opts; exit }

    opts.parse!(ARGV)
    
    if ARGV.empty? and !OPTIONS[:console]
      $stderr.puts "Please provide a file."
      $stderr.puts opts
      exit 1
    end
    
    if MANDATORY_OPTIONS && MANDATORY_OPTIONS.find { |option| OPTIONS[option.to_sym].nil? }
      $stderr.puts opts
      exit 1
    end
  rescue SystemExit => e
    raise e
  rescue Exception => e
    $stderr.puts e.message
    $stderr.puts opts
    exit 1
  end
end

require 'webspeak'

if OPTIONS[:console]
  libs = " -r webspeak/console_app"
  libs << (" -r " + ARGV.join(" -r ")) unless ARGV.empty?
  exec "irb --noinspect #{libs}"
else
  @interpreter = WebSpeak::HTTP::Base.new
  ARGV.each do |file|
    @interpreter.instance_eval(File.read(file), file)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
webspeak-0.0.1 bin/webspeak