Merge branch 'thilko' into destroy-castles

Conflicts:
	lib/homesick/actions.rb
	spec/homesick_spec.rb
This commit is contained in:
Christian Bundy
2013-11-24 19:01:30 -08:00
3 changed files with 66 additions and 0 deletions

View File

@@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
require 'thor'
class Homesick < Thor
@@ -227,6 +228,16 @@ class Homesick < Thor
end
end
desc "destroy CASTLE", "Delete all symlinks and remove the cloned repository"
def destroy(name)
check_castle_existance name, "destroy"
if shell.yes?("This will destroy your castle irreversible! Are you sure?")
unlink(name)
rm_rf repos_dir.join(name)
end
end
protected

View File

@@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
class Homesick
module Actions
# TODO move this to be more like thor's template, empty_directory, etc
@@ -108,6 +109,37 @@ class Homesick
end
end
def rm(file)
say_status "rm #{file}", '', :green unless options[:quiet]
system "rm #{file}" if File.exists?(file)
end
def rm_rf(dir)
say_status "rm -rf #{dir}", '', :green unless options[:quiet]
system "rm -rf #{dir}"
end
def rm_link(target)
target = Pathname.new(target)
if target.symlink?
say_status :unlink, "#{target.expand_path}", :green unless options[:quiet]
FileUtils.rm_rf target
else
say_status :conflict, "#{target} is not a symlink", :red unless options[:quiet]
end
end
def rm(file)
say_status "rm #{file}", '', :green unless options[:quiet]
system "rm #{file}"
end
def rm_r(dir)
say_status "rm -r #{dir}", '', :green unless options[:quiet]
system "rm -r #{dir}"
end
def ln_s(source, destination, config = {})
source = Pathname.new(source)
destination = Pathname.new(destination)