default castle name to constant
This commit is contained in:
@@ -13,6 +13,8 @@ class Homesick < Thor
|
|||||||
GITHUB_NAME_REPO_PATTERN = /\A([A-Za-z_-]+\/[A-Za-z_-]+)\Z/
|
GITHUB_NAME_REPO_PATTERN = /\A([A-Za-z_-]+\/[A-Za-z_-]+)\Z/
|
||||||
SUBDIR_FILENAME = '.homesick_subdir'
|
SUBDIR_FILENAME = '.homesick_subdir'
|
||||||
|
|
||||||
|
DEFAULT_CASTLE_NAME = 'dotfiles'
|
||||||
|
|
||||||
def initialize(args = [], options = {}, config = {})
|
def initialize(args = [], options = {}, config = {})
|
||||||
super
|
super
|
||||||
self.shell = Homesick::Shell.new
|
self.shell = Homesick::Shell.new
|
||||||
@@ -68,7 +70,7 @@ class Homesick < Thor
|
|||||||
|
|
||||||
desc 'pull CASTLE', 'Update the specified castle'
|
desc 'pull CASTLE', 'Update the specified castle'
|
||||||
method_option :all, :type => :boolean, :default => false, :required => false, :desc => 'Update all cloned castles'
|
method_option :all, :type => :boolean, :default => false, :required => false, :desc => 'Update all cloned castles'
|
||||||
def pull(name = 'dotfiles')
|
def pull(name = DEFAULT_CASTLE_NAME)
|
||||||
if options[:all]
|
if options[:all]
|
||||||
inside_each_castle do |castle|
|
inside_each_castle do |castle|
|
||||||
shell.say castle.to_s.gsub(repos_dir.to_s + '/', '') + ':'
|
shell.say castle.to_s.gsub(repos_dir.to_s + '/', '') + ':'
|
||||||
@@ -81,20 +83,20 @@ class Homesick < Thor
|
|||||||
end
|
end
|
||||||
|
|
||||||
desc 'commit CASTLE', "Commit the specified castle's changes"
|
desc 'commit CASTLE', "Commit the specified castle's changes"
|
||||||
def commit(name = 'dotfiles')
|
def commit(name = DEFAULT_CASTLE_NAME)
|
||||||
commit_castle name
|
commit_castle name
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
desc 'push CASTLE', 'Push the specified castle'
|
desc 'push CASTLE', 'Push the specified castle'
|
||||||
def push(name = 'dotfiles')
|
def push(name = DEFAULT_CASTLE_NAME)
|
||||||
push_castle name
|
push_castle name
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
desc 'symlink CASTLE', 'Symlinks all dotfiles from the specified castle'
|
desc 'symlink CASTLE', 'Symlinks all dotfiles from the specified castle'
|
||||||
method_option :force, :default => false, :desc => 'Overwrite existing conflicting symlinks without prompting.'
|
method_option :force, :default => false, :desc => 'Overwrite existing conflicting symlinks without prompting.'
|
||||||
def symlink(name = 'dotfiles')
|
def symlink(name = DEFAULT_CASTLE_NAME)
|
||||||
check_castle_existance(name, 'symlink')
|
check_castle_existance(name, 'symlink')
|
||||||
|
|
||||||
inside castle_dir(name) do
|
inside castle_dir(name) do
|
||||||
@@ -111,7 +113,7 @@ class Homesick < Thor
|
|||||||
end
|
end
|
||||||
|
|
||||||
desc 'track FILE CASTLE', 'add a file to a castle'
|
desc 'track FILE CASTLE', 'add a file to a castle'
|
||||||
def track(file, castle = 'dotfiles')
|
def track(file, castle = DEFAULT_CASTLE_NAME)
|
||||||
castle = Pathname.new(castle)
|
castle = Pathname.new(castle)
|
||||||
file = Pathname.new(file.chomp('/'))
|
file = Pathname.new(file.chomp('/'))
|
||||||
check_castle_existance(castle, 'track')
|
check_castle_existance(castle, 'track')
|
||||||
|
|||||||
Reference in New Issue
Block a user