#!/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 environment # begin exe = Tap::Exe.setup rescue(Tap::Env::ConfigError) # catch errors and exit gracefully # (errors usu from gem loading errors) puts $!.message exit(1) end # # launch tap # 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 %>} 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 puts Lazydoc.usage(__FILE__) puts puts "available commands:" puts commands puts puts "version #{Tap::VERSION} -- #{Tap::WEBSITE}" end exit(0)