From a798f3c562beed883ca9d5abfede01612d9c8e11 Mon Sep 17 00:00:00 2001 From: Joshua Nichols Date: Fri, 2 Apr 2010 00:53:17 -0400 Subject: [PATCH] Add a better error message when a repo's home doesn't exist. --- lib/homesick.rb | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/lib/homesick.rb b/lib/homesick.rb index b02b9c4..fb82908 100644 --- a/lib/homesick.rb +++ b/lib/homesick.rb @@ -45,27 +45,25 @@ class Homesick < Thor end desc "symlink NAME", "Symlinks all dotfiles from the specified castle" - def symlink(home) - unless castle_dir(home).exist? - say_status :error, "Castle #{home} did not exist in #{repos_dir}", :red + def symlink(name) + unless castle_dir(name).exist? + say_status :error, "Could not symlink #{name}, expected #{castle_dir(name)} exist and contain dotfiles", :red exit(1) + end - else - inside castle_dir(home) do - files = Pathname.glob('.*').reject{|a| [".",".."].include?(a.to_s)} - files.each do |path| - absolute_path = path.expand_path + inside castle_dir(name) do + files = Pathname.glob('.*').reject{|a| [".",".."].include?(a.to_s)} + files.each do |path| + absolute_path = path.expand_path - inside home_dir do - adjusted_path = (home_dir + path).basename + inside home_dir do + adjusted_path = (home_dir + path).basename - ln_s absolute_path, adjusted_path - end + ln_s absolute_path, adjusted_path end end end - end desc "list", "List cloned castles"