#!/usr/local/bin/ruby # usage: tap {options} [args] # # examples: # tap generate root . # generates a root dir # tap run taskname --option input # runs the 'taskname' task # # help: # tap help # prints this help # tap command --help # prints help for 'command' # require "#{File.dirname(__FILE__)}/../lib/tap.rb" require 'tap/exe' # setup the environment begin $DEBUG = true if ARGV.delete('-d-') env = Tap::Exe.instantiate rescue(Tap::Env::ConfigError) # catch errors and exit gracefully # (errors usu from gem loading errors) puts $!.message exit(1) end # # setup after script # at_exit do begin eval(env.after) if env.after != nil rescue(Exception) puts "Error in after script." env.handle_error($!) exit(1) end end # # run before script # begin eval(env.before) if env.before != nil rescue(Exception) puts "Error in before script." env.handle_error($!) exit(1) end # # run tap # begin env.activate env.run do # give some help require 'tap/support/command_line' puts Tap::Support::CommandLine.usage(__FILE__) puts puts "available commands:" puts env.summarize(:commands) puts puts "version #{Tap::VERSION} -- #{Tap::WEBSITE}" end rescue env.handle_error($!) end exit(0)