#!/usr/bin/env ruby # usage: tap {options} [args] # # Launches a tap command. # # 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" # # setup the application # begin app = Tap::App.setup rescue(Tap::Env::ConfigError) # catch errors and exit gracefully # (errors usu from gem loading errors) puts $!.message exit(1) end # # launch the command # commands = app.env.manifest do |env| env.root.glob(:cmd, "**/*.rb") end case command = ARGV.shift.to_s when '', '--help' template = %Q{<% unless minimap.empty? || count <= 1 %> <%= env_key %>: <% end %> <% minimap.each do |key, path| %> <%= key.ljust(width) %> <% end %>} puts Lazydoc.usage(__FILE__) puts puts "available commands:" puts commands.summarize(template) puts puts "version #{Tap::VERSION} -- #{Tap::WEBSITE}" else if path = commands.seek(command) load path else puts "Unknown command: '#{command}'" puts "Type 'tap --help' for usage information." end end exit(0)