First pass at castle generator task.

This commit is contained in:
Joshua Nichols
2010-04-08 01:05:34 -04:00
parent e1901b3a83
commit c9399064e0
2 changed files with 46 additions and 0 deletions

View File

@@ -75,6 +75,27 @@ class Homesick < Thor
end
end
desc "generate PATH", "generate a homesick-ready git repo at PATH"
def generate(castle)
castle = Pathname.new(castle).expand_path
github_user = `git config github.user`.chomp
github_user = nil if github_user == ""
github_repo = castle.basename
empty_directory castle
inside castle do
git_init
if github_user
url = "git@github.com:#{github_user}/#{github_repo}.git"
git_remote_add 'origin', url
end
empty_directory "home"
end
end
protected
def home_dir