mirror of
https://github.com/deadc0de6/dotdrop.git
synced 2026-02-16 10:36:11 +00:00
adding link_by_default option for #49
This commit is contained in:
@@ -451,6 +451,7 @@ the following entries:
|
|||||||
* `banner`: display the banner (default *true*)
|
* `banner`: display the banner (default *true*)
|
||||||
* `longkey`: use long keys for dotfiles when importing (default *false*)
|
* `longkey`: use long keys for dotfiles when importing (default *false*)
|
||||||
* `keepdot`: preserve leading dot when importing hidden file in the `dotpath` (default *false*)
|
* `keepdot`: preserve leading dot when importing hidden file in the `dotpath` (default *false*)
|
||||||
|
* `link_by_default`: when importing a dotfile set `link` to that value per default (default *false*)
|
||||||
|
|
||||||
* **dotfiles** entry: a list of dotfiles
|
* **dotfiles** entry: a list of dotfiles
|
||||||
* When `link` is true, dotdrop will create a symlink instead of copying. Template generation (as in [template](#template)) is not supported when `link` is true.
|
* When `link` is true, dotdrop will create a symlink instead of copying. Template generation (as in [template](#template)) is not supported when `link` is true.
|
||||||
|
|||||||
@@ -5,5 +5,6 @@ config:
|
|||||||
banner: true
|
banner: true
|
||||||
longkey: false
|
longkey: false
|
||||||
keepdot: false
|
keepdot: false
|
||||||
|
link_by_default: false
|
||||||
dotfiles:
|
dotfiles:
|
||||||
profiles:
|
profiles:
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ class Cfg:
|
|||||||
key_banner = 'banner'
|
key_banner = 'banner'
|
||||||
key_long = 'longkey'
|
key_long = 'longkey'
|
||||||
key_keepdot = 'keepdot'
|
key_keepdot = 'keepdot'
|
||||||
|
key_deflink = 'link_by_default'
|
||||||
|
|
||||||
# actions keys
|
# actions keys
|
||||||
key_actions = 'actions'
|
key_actions = 'actions'
|
||||||
@@ -57,6 +58,7 @@ class Cfg:
|
|||||||
default_link = False
|
default_link = False
|
||||||
default_longkey = False
|
default_longkey = False
|
||||||
default_keepdot = False
|
default_keepdot = False
|
||||||
|
default_link_by_default = False
|
||||||
|
|
||||||
def __init__(self, cfgpath):
|
def __init__(self, cfgpath):
|
||||||
if not os.path.exists(cfgpath):
|
if not os.path.exists(cfgpath):
|
||||||
@@ -288,6 +290,8 @@ class Cfg:
|
|||||||
self.lnk_settings[self.key_long] = self.default_longkey
|
self.lnk_settings[self.key_long] = self.default_longkey
|
||||||
if self.key_keepdot not in self.lnk_settings:
|
if self.key_keepdot not in self.lnk_settings:
|
||||||
self.lnk_settings[self.key_keepdot] = self.default_keepdot
|
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):
|
def abs_dotpath(self, path):
|
||||||
"""transform path to an absolute path based on config path"""
|
"""transform path to an absolute path based on config path"""
|
||||||
|
|||||||
@@ -279,7 +279,8 @@ def importer(opts, conf, paths):
|
|||||||
|
|
||||||
# create a new dotfile
|
# create a new dotfile
|
||||||
dotfile = Dotfile('', dst, src)
|
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
|
dotfile = new_dotfile
|
||||||
|
|
||||||
# prepare hierarchy for dotfile
|
# prepare hierarchy for dotfile
|
||||||
@@ -293,11 +294,11 @@ def importer(opts, conf, paths):
|
|||||||
cmd = ['cp', '-R', '-L', dst, srcf]
|
cmd = ['cp', '-R', '-L', dst, srcf]
|
||||||
if opts['dry']:
|
if opts['dry']:
|
||||||
LOG.dry('would run: {}'.format(' '.join(cmd)))
|
LOG.dry('would run: {}'.format(' '.join(cmd)))
|
||||||
if opts['link']:
|
if linkit:
|
||||||
LOG.dry('would symlink {} to {}'.format(srcf, dst))
|
LOG.dry('would symlink {} to {}'.format(srcf, dst))
|
||||||
else:
|
else:
|
||||||
run(cmd, raw=False, debug=opts['debug'])
|
run(cmd, raw=False, debug=opts['debug'])
|
||||||
if opts['link']:
|
if linkit:
|
||||||
remove(dst)
|
remove(dst)
|
||||||
os.symlink(srcf, dst)
|
os.symlink(srcf, dst)
|
||||||
if retconf:
|
if retconf:
|
||||||
|
|||||||
Reference in New Issue
Block a user