From 34a63ecbfeaf5451ba4c949032cd891865527cfd Mon Sep 17 00:00:00 2001 From: deadc0de6 Date: Wed, 26 Sep 2018 08:42:05 +0200 Subject: [PATCH] allows to select specific keys for #4 --- dotdrop/dotdrop.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/dotdrop/dotdrop.py b/dotdrop/dotdrop.py index e087348..5de5d46 100644 --- a/dotdrop/dotdrop.py +++ b/dotdrop/dotdrop.py @@ -41,7 +41,7 @@ USAGE = """ {} Usage: - dotdrop install [-tfndVb] [-c ] [-p ] + dotdrop install [-tfndVb] [-c ] [-p ] [...] dotdrop import [-ldVb] [-c ] [-p ] ... dotdrop compare [-Vb] [-c ] [-p ] [-o ] [-i ...] @@ -75,13 +75,17 @@ Options: ########################################################### -def install(opts, conf, temporary=False): - """install all dotfiles for this profile""" +def install(opts, conf, temporary=False, keys=[]): + """install dotfiles for this profile""" dotfiles = conf.get_dotfiles(opts['profile']) - if dotfiles == []: - msg = 'no dotfiles defined for this profile (\"{}\")' + if keys: + # 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'])) return False + t = Templategen(opts['profile'], base=opts['dotpath'], variables=opts['variables'], debug=opts['debug']) tmpdir = None @@ -366,7 +370,9 @@ def main(): elif args['install']: # install the dotfiles stored in dotdrop - ret = install(opts, conf, temporary=args['--temp']) + keys = args[''] + ret = install(opts, conf, temporary=args['--temp'], + keys=keys) elif args['compare']: # compare local dotfiles with dotfiles stored in dotdrop