mirror of
https://github.com/deadc0de6/dotdrop.git
synced 2026-02-12 11:53:31 +00:00
fix update usage (adding profile switch)
This commit is contained in:
@@ -46,7 +46,7 @@ Usage:
|
|||||||
dotdrop import [-ldVb] [-c <path>] [-p <profile>] <paths>...
|
dotdrop import [-ldVb] [-c <path>] [-p <profile>] <paths>...
|
||||||
dotdrop compare [-Vb] [-c <path>] [-p <profile>]
|
dotdrop compare [-Vb] [-c <path>] [-p <profile>]
|
||||||
[-o <opts>] [-C <file>...] [-i <pattern>...]
|
[-o <opts>] [-C <file>...] [-i <pattern>...]
|
||||||
dotdrop update [-fdVb] [-c <path>] <paths>...
|
dotdrop update [-fdVb] [-c <path>] [-p <profile>] <paths>...
|
||||||
dotdrop listfiles [-VTb] [-c <path>] [-p <profile>]
|
dotdrop listfiles [-VTb] [-c <path>] [-p <profile>]
|
||||||
dotdrop list [-Vb] [-c <path>]
|
dotdrop list [-Vb] [-c <path>]
|
||||||
dotdrop --help
|
dotdrop --help
|
||||||
|
|||||||
@@ -28,6 +28,27 @@ class Updater:
|
|||||||
self.debug = debug
|
self.debug = debug
|
||||||
self.log = Logger()
|
self.log = Logger()
|
||||||
|
|
||||||
|
def update(self, path, profile):
|
||||||
|
"""update the dotfile installed on path"""
|
||||||
|
if not os.path.lexists(path):
|
||||||
|
self.log.err('\"{}\" does not exist!'.format(path))
|
||||||
|
return False
|
||||||
|
left = self._normalize(path)
|
||||||
|
dotfile = self._get_dotfile(left, profile)
|
||||||
|
if not dotfile:
|
||||||
|
return False
|
||||||
|
if self.debug:
|
||||||
|
self.log.dbg('updating {} from {}'.format(dotfile, path))
|
||||||
|
|
||||||
|
right = os.path.join(self.conf.abs_dotpath(self.dotpath), dotfile.src)
|
||||||
|
# expands user
|
||||||
|
left = os.path.expanduser(left)
|
||||||
|
right = os.path.expanduser(right)
|
||||||
|
# go through all files and update
|
||||||
|
if os.path.isdir(path):
|
||||||
|
return self._handle_dir(left, right)
|
||||||
|
return self._handle_file(left, right)
|
||||||
|
|
||||||
def _normalize(self, path):
|
def _normalize(self, path):
|
||||||
"""normalize the path to match dotfile"""
|
"""normalize the path to match dotfile"""
|
||||||
path = os.path.expanduser(path)
|
path = os.path.expanduser(path)
|
||||||
@@ -52,27 +73,6 @@ class Updater:
|
|||||||
return None
|
return None
|
||||||
return subs[0]
|
return subs[0]
|
||||||
|
|
||||||
def update(self, path, profile):
|
|
||||||
"""update the dotfile installed on path"""
|
|
||||||
if not os.path.lexists(path):
|
|
||||||
self.log.err('\"{}\" does not exist!'.format(path))
|
|
||||||
return False
|
|
||||||
left = self._normalize(path)
|
|
||||||
dotfile = self._get_dotfile(left, profile)
|
|
||||||
if not dotfile:
|
|
||||||
return False
|
|
||||||
if self.debug:
|
|
||||||
self.log.dbg('updating {} from {}'.format(dotfile, path))
|
|
||||||
|
|
||||||
right = os.path.join(self.conf.abs_dotpath(self.dotpath), dotfile.src)
|
|
||||||
# expands user
|
|
||||||
left = os.path.expanduser(left)
|
|
||||||
right = os.path.expanduser(right)
|
|
||||||
# go through all files and update
|
|
||||||
if os.path.isdir(path):
|
|
||||||
return self._handle_dir(left, right)
|
|
||||||
return self._handle_file(left, right)
|
|
||||||
|
|
||||||
def _is_template(self, path):
|
def _is_template(self, path):
|
||||||
if not Templategen.is_template(path):
|
if not Templategen.is_template(path):
|
||||||
return False
|
return False
|
||||||
|
|||||||
Reference in New Issue
Block a user