Sha256: 38546c1a865d52df68725ab0d23b89f6435f8a1417ed46d397e354b6cf23a920

Contents?: true

Size: 1.38 KB

Versions: 3

Compression:

Stored size: 1.38 KB

Contents

#!/usr/bin/env ruby
# usage: tap <command> {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)

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
tap-0.18.0 bin/tap
tap-0.17.0 bin/tap
tap-0.17.1 bin/tap