Merge branch 'thilko' into destroy-castles
Conflicts: lib/homesick/actions.rb spec/homesick_spec.rb
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user