bin/tap in tap-0.10.0 vs bin/tap in tap-0.10.1
- old
+ new
@@ -8,42 +8,19 @@
# help:
# tap help # prints this help
# tap command --help # prints help for 'command'
#
-tap_root_dir = File.dirname(__FILE__) + "/.."
-require "#{tap_root_dir}/lib/tap.rb"
+require "#{File.dirname(__FILE__)}/../lib/tap.rb"
+require 'tap/exe'
# setup the environment
begin
$DEBUG = true if ARGV.delete('-d-')
- before = nil
- after = nil
- aliases = nil
+ env = Tap::Exe.instantiate
- app = Tap::App.instance
- env = Tap::Env.instantiate(app, Tap::Env.load_config(Tap::Env::GLOBAL_CONFIG_FILE), app.logger) do |unhandled_configs|
- before = unhandled_configs.delete(:before)
- after = unhandled_configs.delete(:after)
-
- aliases = unhandled_configs.delete(:alias)
- Tap::Support::Validation.validate(aliases, [Hash]) if aliases
-
- unless unhandled_configs.empty?
- local.log(:warn, "ignoring non-env configs: #{unhandled_configs.keys.join(',')}", Logger::DEBUG)
- end
- end
-
- # add all gems if no gems are specified (Note this is VERY SLOW ~ 1/3 the overhead for tap)
- if !File.exists?(Tap::Env::DEFAULT_CONFIG_FILE)
- env.gems = Tap::Env.known_gems(true)
- end
-
- tap = Tap::Env.instance_for(tap_root_dir)
- env.push(tap)
-
rescue(Tap::Env::ConfigError)
# catch errors and exit gracefully
# (errors usu from gem loading errors)
puts $!.message
exit(1)
@@ -53,11 +30,11 @@
# setup after script
#
at_exit do
begin
- eval(after) if after != nil
+ eval(env.after) if env.after != nil
rescue(Exception)
puts "Error in after script."
env.handle_error($!)
exit(1)
end
@@ -66,11 +43,11 @@
#
# run before script
#
begin
- eval(before) if before != nil
+ eval(env.before) if env.before != nil
rescue(Exception)
puts "Error in before script."
env.handle_error($!)
exit(1)
end
@@ -79,34 +56,19 @@
# run tap
#
begin
env.activate
-
- command = ARGV.shift
- if aliases && aliases.has_key?(command)
- aliases[command].reverse_each {|arg| ARGV.unshift(arg)}
- command = ARGV.shift
- end
-
- case command
- when nil, '--help'
+ 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}"
- else
- if path = env.search(:commands, command)
- load path # run the command, if it exists
- else
- puts "Unknown command: '#{command}'"
- puts "Type 'tap help' for usage information."
- end
+ puts "version #{Tap::VERSION} -- #{Tap::WEBSITE}"
end
rescue
env.handle_error($!)
end
\ No newline at end of file