Sha256: aa690d21bf54c44d47594ef887c6b70c3bdc17905bfee8947dbfd1a7f83863e9

Contents?: true

Size: 838 Bytes

Versions: 2

Compression:

Stored size: 838 Bytes

Contents

# -*- coding: utf-8 -*-
Gemirro::CLI.options.command 'init' do
  banner 'Usage: gemirro init [DIRECTORY] [OPTIONS]'
  description 'Sets up a new mirror'
  separator "\nOptions:\n"
  on :force, 'Force overwrite'

  run do |opts, args|
    directory = File.expand_path(args[0] || Dir.pwd)
    template  = Gemirro::Configuration.template_directory

    Dir.mkdir(directory) unless File.directory?(directory)

    if opts[:force]
      FileUtils.cp_r(File.join(template, '.'), directory)
    else
      Dir.glob("#{template}/**/*", File::FNM_DOTMATCH).each do |file|
        next if ['.', '..'].include?(File.basename(file))
        dest = File.join(directory, file.gsub(/^#{template}/, ''))
        next if File.exist?(dest)
        FileUtils.cp_r(file, dest)
      end
    end

    puts "Initialized empty mirror in #{directory}"
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
gemirro-0.13.2 lib/gemirro/cli/init.rb
gemirro-0.13.1 lib/gemirro/cli/init.rb