Sha256: 0808e2a1f0caeb923a96df3f09fa9a7890ba0cc66b8e5d1f8c91500e37fb3b18

Contents?: true

Size: 1.56 KB

Versions: 2

Compression:

Stored size: 1.56 KB

Contents

#!/usr/bin/env ruby

require 'optparse'

OptionParser.new do |opts|
  opts.banner = "Usage: #{File.basename($0)} [path]"

  opts.on("-h", "--help", "Displays this help info") do
    puts opts
    exit 0
  end

  begin
    opts.parse!(ARGV)
  rescue OptionParser::ParseError => e
    warn e.message
    puts opts
    exit 1
  end
end

begin
  require 'capitate'
rescue LoadError
  require 'rubygems'
  require 'capitate'
end


class CapitateBin
  class << self
    include Capitate::Plugins::Templates    
  end
end

if ARGV.empty?
  abort "Please specify the directory to capify, e.g. `#{File.basename($0)} .'"
elsif !File.exists?(ARGV.first)
  abort "`#{ARGV.first}' does not exist."
elsif !File.directory?(ARGV.first)
  abort "`#{ARGV.first}' is not a directory."
elsif ARGV.length > 1
  abort "Too many arguments; please specify only the directory to capitate."
end

base = ARGV.shift

puts <<-EOS

  Generating capistrano configuration...

EOS

files = { "Capfile" => "capistrano/Capfile" }

files.each do |file, template|
  file = File.join(base, file)
  if File.exists?(file)
    warn "`#{file}' already exists"
  elsif File.exists?(file.downcase)
    warn "`#{file.downcase}' exists, which could conflict with `#{file}'"
  elsif !File.exists?(File.dirname(file))
    warn "Directory `#{File.dirname(file)}' does not exist"
  else
    # Write Capfile
    CapitateBin.write(template, file)
  end
end

puts <<-EOS

  You now need to create and set you deployment "profile" in the Capfile.
  This is currently a manual process, see the documentation on profiles 
  for more information.

EOS


Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
capitate-0.1.8 bin/capitate
capitate-0.1.9 bin/capitate