mirror of
https://github.com/deadc0de6/dotdrop.git
synced 2026-02-09 18:09:17 +00:00
adding link_by_default option for #49
This commit is contained in:
@@ -28,6 +28,7 @@ class Cfg:
|
||||
key_banner = 'banner'
|
||||
key_long = 'longkey'
|
||||
key_keepdot = 'keepdot'
|
||||
key_deflink = 'link_by_default'
|
||||
|
||||
# actions keys
|
||||
key_actions = 'actions'
|
||||
@@ -57,6 +58,7 @@ class Cfg:
|
||||
default_link = False
|
||||
default_longkey = False
|
||||
default_keepdot = False
|
||||
default_link_by_default = False
|
||||
|
||||
def __init__(self, cfgpath):
|
||||
if not os.path.exists(cfgpath):
|
||||
@@ -288,6 +290,8 @@ class Cfg:
|
||||
self.lnk_settings[self.key_long] = self.default_longkey
|
||||
if self.key_keepdot not in self.lnk_settings:
|
||||
self.lnk_settings[self.key_keepdot] = self.default_keepdot
|
||||
if self.key_deflink not in self.lnk_settings:
|
||||
self.lnk_settings[self.key_deflink] = self.default_link_by_default
|
||||
|
||||
def abs_dotpath(self, path):
|
||||
"""transform path to an absolute path based on config path"""
|
||||
|
||||
@@ -279,7 +279,8 @@ def importer(opts, conf, paths):
|
||||
|
||||
# create a new dotfile
|
||||
dotfile = Dotfile('', dst, src)
|
||||
retconf, new_dotfile = conf.new(dotfile, opts['profile'], opts['link'])
|
||||
linkit = opts['link'] or opts['link_by_default']
|
||||
retconf, new_dotfile = conf.new(dotfile, opts['profile'], linkit)
|
||||
dotfile = new_dotfile
|
||||
|
||||
# prepare hierarchy for dotfile
|
||||
@@ -293,11 +294,11 @@ def importer(opts, conf, paths):
|
||||
cmd = ['cp', '-R', '-L', dst, srcf]
|
||||
if opts['dry']:
|
||||
LOG.dry('would run: {}'.format(' '.join(cmd)))
|
||||
if opts['link']:
|
||||
if linkit:
|
||||
LOG.dry('would symlink {} to {}'.format(srcf, dst))
|
||||
else:
|
||||
run(cmd, raw=False, debug=opts['debug'])
|
||||
if opts['link']:
|
||||
if linkit:
|
||||
remove(dst)
|
||||
os.symlink(srcf, dst)
|
||||
if retconf:
|
||||
|
||||
Reference in New Issue
Block a user