Added track command.
* Moves a specified file into the specified castle. * Symlinks it into its original position. Signed-off-by: Joshua Nichols <josh@technicalpickles.com>
This commit is contained in:
committed by
Joshua Nichols
parent
4776651b27
commit
58767454b3
@@ -75,6 +75,32 @@ class Homesick < Thor
|
||||
end
|
||||
end
|
||||
|
||||
desc "track FILE CASTLE", "add a file to a castle"
|
||||
def track(file, castle)
|
||||
castle = Pathname.new(castle)
|
||||
file = Pathname.new(file)
|
||||
check_castle_existance(castle, 'track')
|
||||
|
||||
github_user = `git config github.user`.chomp
|
||||
github_user = nil if github_user == ""
|
||||
github_repo = castle.basename
|
||||
|
||||
absolute_path = file.expand_path
|
||||
castle_path = castle_dir(castle)
|
||||
mv absolute_path, castle_path
|
||||
|
||||
inside castle_path do
|
||||
system "git add #{file.basename}"
|
||||
system "git commit -m \"Added #{file.basename}\""
|
||||
end
|
||||
|
||||
inside home_dir do
|
||||
absolute_path = castle_dir(castle) + file.basename
|
||||
home_path = home_dir + file
|
||||
ln_s absolute_path, home_path
|
||||
end
|
||||
end
|
||||
|
||||
desc "list", "List cloned castles"
|
||||
def list
|
||||
#require 'ruby-debug'; breakpoint
|
||||
@@ -94,7 +120,6 @@ class Homesick < Thor
|
||||
github_user = nil if github_user == ""
|
||||
github_repo = castle.basename
|
||||
|
||||
|
||||
empty_directory castle
|
||||
inside castle do
|
||||
git_init
|
||||
@@ -107,6 +132,7 @@ class Homesick < Thor
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
protected
|
||||
|
||||
def home_dir
|
||||
|
||||
@@ -59,6 +59,22 @@ class Homesick
|
||||
system "git pull --quiet" unless options[:pretend]
|
||||
end
|
||||
|
||||
def mv(source, destination, config = {})
|
||||
source = Pathname.new(source)
|
||||
destination = Pathname.new(destination + source.basename)
|
||||
|
||||
if destination.exist?
|
||||
say_status :conflict, "#{destination} exists", :red unless options[:quiet]
|
||||
|
||||
if options[:force] || shell.file_collision(destination) { source }
|
||||
system "mv #{source} #{destination}" unless options[:pretend]
|
||||
end
|
||||
else
|
||||
# this needs some sort of message here.
|
||||
system "mv #{source} #{destination}" unless options[:pretend]
|
||||
end
|
||||
end
|
||||
|
||||
def ln_s(source, destination, config = {})
|
||||
source = Pathname.new(source)
|
||||
destination = Pathname.new(destination)
|
||||
|
||||
Reference in New Issue
Block a user