Added ability for methods to be overrode, through the pretend and quiet
options, skipping their default behaviour if so.
This commit is contained in:
@@ -8,7 +8,7 @@ module Homesick
|
||||
destination = Pathname.new(destination + source.basename)
|
||||
|
||||
if destination.exist?
|
||||
say_status :conflict, "#{destination} exists", :red unless options[:quiet]
|
||||
say_status :conflict, "#{destination} exists", :red
|
||||
|
||||
FileUtils.mv source, destination if (options[:force] || shell.file_collision(destination) { source }) && !options[:pretend]
|
||||
else
|
||||
@@ -18,7 +18,7 @@ module Homesick
|
||||
end
|
||||
|
||||
def rm_rf(dir)
|
||||
say_status "rm -rf #{dir}", '', :green unless options[:quiet]
|
||||
say_status "rm -rf #{dir}", '', :green
|
||||
FileUtils.rm_r dir, force: true
|
||||
end
|
||||
|
||||
@@ -26,20 +26,20 @@ module Homesick
|
||||
target = Pathname.new(target)
|
||||
|
||||
if target.symlink?
|
||||
say_status :unlink, "#{target.expand_path}", :green unless options[:quiet]
|
||||
say_status :unlink, "#{target.expand_path}", :green
|
||||
FileUtils.rm_rf target
|
||||
else
|
||||
say_status :conflict, "#{target} is not a symlink", :red unless options[:quiet]
|
||||
say_status :conflict, "#{target} is not a symlink", :red
|
||||
end
|
||||
end
|
||||
|
||||
def rm(file)
|
||||
say_status "rm #{file}", '', :green unless options[:quiet]
|
||||
say_status "rm #{file}", '', :green
|
||||
FileUtils.rm file, force: true
|
||||
end
|
||||
|
||||
def rm_r(dir)
|
||||
say_status "rm -r #{dir}", '', :green unless options[:quiet]
|
||||
say_status "rm -r #{dir}", '', :green
|
||||
FileUtils.rm_r dir
|
||||
end
|
||||
|
||||
@@ -64,16 +64,16 @@ module Homesick
|
||||
def handle_symlink_action(action, source, destination)
|
||||
case action
|
||||
when :identical
|
||||
say_status :identical, destination.expand_path, :blue unless options[:quiet]
|
||||
say_status :identical, destination.expand_path, :blue
|
||||
when :symlink_conflict
|
||||
say_status :conflict,
|
||||
"#{destination} exists and points to #{destination.readlink}",
|
||||
:red unless options[:quiet]
|
||||
:red
|
||||
|
||||
FileUtils.rm destination
|
||||
FileUtils.ln_s source, destination, force: true unless options[:pretend]
|
||||
when :conflict
|
||||
say_status :conflict, "#{destination} exists", :red unless options[:quiet]
|
||||
say_status :conflict, "#{destination} exists", :red
|
||||
|
||||
if collision_accepted?
|
||||
FileUtils.rm_r destination, force: true unless options[:pretend]
|
||||
@@ -82,7 +82,7 @@ module Homesick
|
||||
else
|
||||
say_status :symlink,
|
||||
"#{source.expand_path} to #{destination.expand_path}",
|
||||
:green unless options[:quiet]
|
||||
:green
|
||||
FileUtils.ln_s source, destination unless options[:pretend]
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user