1
0
mirror of https://github.com/deadc0de6/dotdrop.git synced 2026-02-08 05:04:17 +00:00

allows to select specific keys for #4

This commit is contained in:
deadc0de6
2018-09-26 08:42:05 +02:00
parent 0d4ce18e49
commit 34a63ecbfe

View File

@@ -41,7 +41,7 @@ USAGE = """
{} {}
Usage: Usage:
dotdrop install [-tfndVb] [-c <path>] [-p <profile>] dotdrop install [-tfndVb] [-c <path>] [-p <profile>] [<key>...]
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>] [-i <name>...] [-o <opts>] [-i <name>...]
@@ -75,13 +75,17 @@ Options:
########################################################### ###########################################################
def install(opts, conf, temporary=False): def install(opts, conf, temporary=False, keys=[]):
"""install all dotfiles for this profile""" """install dotfiles for this profile"""
dotfiles = conf.get_dotfiles(opts['profile']) dotfiles = conf.get_dotfiles(opts['profile'])
if dotfiles == []: if keys:
msg = 'no dotfiles defined for this profile (\"{}\")' # filtered dotfiles to install
dotfiles = [d for d in dotfiles if d.key in set(keys)]
if not dotfiles:
msg = 'no dotfiles to install for this profile (\"{}\")'
LOG.err(msg.format(opts['profile'])) LOG.err(msg.format(opts['profile']))
return False return False
t = Templategen(opts['profile'], base=opts['dotpath'], t = Templategen(opts['profile'], base=opts['dotpath'],
variables=opts['variables'], debug=opts['debug']) variables=opts['variables'], debug=opts['debug'])
tmpdir = None tmpdir = None
@@ -366,7 +370,9 @@ def main():
elif args['install']: elif args['install']:
# install the dotfiles stored in dotdrop # install the dotfiles stored in dotdrop
ret = install(opts, conf, temporary=args['--temp']) keys = args['<key>']
ret = install(opts, conf, temporary=args['--temp'],
keys=keys)
elif args['compare']: elif args['compare']:
# compare local dotfiles with dotfiles stored in dotdrop # compare local dotfiles with dotfiles stored in dotdrop