bin/tap in tap-0.12.4 vs bin/tap in tap-0.17.0
- old
+ new
@@ -1,9 +1,9 @@
#!/usr/bin/env ruby
-# usage: tap <command> {options} [args] [-d-]
+# usage: tap <command> {options} [args]
#
-# Launches a tap command. To enable debugging, append the -d- superflag.
+# Launches a tap command.
#
# examples:
# tap generate root . # generates a root dir
# tap run taskname --option input # runs the 'taskname' task
#
@@ -12,60 +12,56 @@
# tap command --help # prints help for 'command'
#
require "#{File.dirname(__FILE__)}/../lib/tap.rb"
+#
# setup the environment
+#
+
begin
- env = Tap::Exe.setup(ARGV)
+ exe = Tap::Exe.setup
rescue(Tap::Env::ConfigError)
# catch errors and exit gracefully
# (errors usu from gem loading errors)
puts $!.message
exit(1)
end
#
-# setup after script
+# launch tap
#
-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
+exe.activate
+exe.launch(ARGV) do
+ template = %Q{<% unless entries.empty? || count <= 1 %>
+<%= env_key %>:
+<% end %>
+<% entries.each do |key, path| %>
+ <%= key.ljust(width) %>
+<% 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.execute(ARGV) do
- puts Lazydoc.usage(__FILE__)
- puts
- puts "available commands:"
- puts env.summarize(:commands)
- puts
- puts "version #{Tap::VERSION} -- #{Tap::WEBSITE}"
+ commands = exe.manifest(:command).inspect(template,
+ :count => 0,
+ :width => 10
+ ) do |templater, globals|
+ entries = templater.manifest.minimap
+ templater.entries = entries
+
+ # determine width, count
+ width = globals[:width]
+ entries.each do |key, path|
+ width = key.length if width < key.length
+ end
+ globals[:width] = width
+ globals[:count] += 1 unless entries.empty?
end
-rescue
- env.handle_error($!)
+
+ puts Lazydoc.usage(__FILE__)
+ puts
+ puts "available commands:"
+ puts commands
+ puts
+ puts "version #{Tap::VERSION} -- #{Tap::WEBSITE}"
end
exit(0)
\ No newline at end of file