Sha256: 5b4de1bcb134893829d22484f86c15b7135ccc2fe442242ca2ad1ac47e13542f

Contents?: true

Size: 863 Bytes

Versions: 1

Compression:

Stored size: 863 Bytes

Contents

command :copy do |c|
  c.workflow :git
  c.desc "Copies a file from one location to another, while maintaining history"
  c.opt :force, "Forces the copy, ignoring overwrites", :short => "-f"
  c.opt :"dry-run", "Doesn't actually move files - only prints what would happen", :short => "-n"
  c.synonym :cp
  c.before do |opts, args|
    if args.size < 2
      Amp::UI.say "Usage: amp copy source [other-sources...] destination"
      c.break
    elsif args.size > 2 && !File.directory?(args.last)
      Amp::UI.say "If you want to copy more than 1 file, your destination must" +
                  " be a directory."
      c.break
    end
  end
  
  c.on_run do |opts, args|
    repo = opts[:repository]
    
    sources = args[0..-2]
    destination = args.last
    sources.each do |source|
      repo.staging_area.copy(source, destination, opts)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
amp-0.5.3 lib/amp/commands/commands/workflows/git/copy.rb