Sha256: 32d80edb218f59ad9cac1398d3f9f631401de8d537da3b8eab0528734020de72

Contents?: true

Size: 1.16 KB

Versions: 7

Compression:

Stored size: 1.16 KB

Contents

#!/usr/bin/env ruby

require 'fileutils'

def usage
  puts <<-eos
Initialize a murlsh site instance in a web directory.

usage: murlsh DESTINATION_DIRECTORY

eos
end

def ask(prompt, default)
  print "#{prompt} [#{default}] "
  answer = $stdin.gets.strip
  answer = default if answer.empty?
  answer
end

def cp_r_safe(sources, dest, options)
  sources.each do |source|
    new = File.join(dest, File.split(File.expand_path(source)).last)

    if File.directory?(source)
      FileUtils.mkdir_p(new, options)
      cp_r_safe(Dir.entries(source).
        reject { |f| %w{. ..}.include?(f) }.
        map { |f| File.join(source, f) }, new, options)
    else
      answer = if File.exists?(new)
        ask("#{new} exists. Overwrite?", 'n')
      else
        'y'
      end

      FileUtils.copy(source, new, options) if answer == 'y'
    end
  end

end

if ARGV.empty?; usage; exit 1; end

dest_dir = ARGV[0]

cp_r_safe(
  %w{.htaccess config.ru config.yaml plugins/ public/ Rakefile}.map { |x| 
    File.join(File.dirname(__FILE__), '..', x) }, dest_dir, :verbose => true)

FileUtils.mkdir_p('tmp', :verbose => true)

puts <<eos
Next steps:

cd #{dest_dir}
edit config.yaml
rake init
eos

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
murlsh-1.2.1 bin/murlsh
murlsh-1.2.0 bin/murlsh
murlsh-1.1.0 bin/murlsh
murlsh-1.0.0 bin/murlsh
murlsh-0.11.0 bin/murlsh
murlsh-0.10.0 bin/murlsh
murlsh-0.9.0 bin/murlsh