From b0894633375cdc83641b31f32001fec413e94443 Mon Sep 17 00:00:00 2001 From: deadc0de6 Date: Sat, 29 Sep 2018 16:12:07 +0200 Subject: [PATCH] rename --files to --file and refactor usage option for compare --- README.md | 2 +- dotdrop/dotdrop.py | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 5019719..b74f39a 100644 --- a/README.md +++ b/README.md @@ -550,7 +550,7 @@ changes to apply to the template: * Use dotdrop's `compare` command ```bash # use compare to identify change(s) -$ dotdrop compare --files=~/.vimrc +$ dotdrop compare --file=~/.vimrc ``` * Install the dotfiles to a temporary directory (using the `install` command and the diff --git a/dotdrop/dotdrop.py b/dotdrop/dotdrop.py index 129fe16..ebe4526 100644 --- a/dotdrop/dotdrop.py +++ b/dotdrop/dotdrop.py @@ -45,7 +45,7 @@ Usage: dotdrop install [-tfndVbD] [-c ] [-p ] [...] dotdrop import [-ldVb] [-c ] [-p ] ... dotdrop compare [-Vb] [-c ] [-p ] - [-o ] [-C ] [-i ...] + [-o ] [-C ...] [-i ...] dotdrop update [-fdVb] [-c ] ... dotdrop listfiles [-VTb] [-c ] [-p ] dotdrop list [-Vb] [-c ] @@ -55,8 +55,8 @@ Usage: Options: -p --profile= Specify the profile to use [default: {}]. -c --cfg= Path to the config [default: config.yaml]. - -C --files= Comma separated list of files to compare. - -i --ignore= File name to ignore when diffing. + -C --file= Path of dotfile to compare. + -i --ignore= Pattern to ignore when diffing. -o --dopts= Diff options [default: ]. -n --nodiff Do not diff when installing. -t --temp Install to a temporary directory for review. @@ -177,7 +177,7 @@ def _select(selections, dotfiles): return selected -def compare(opts, conf, tmp, focus=None, ignore=[]): +def compare(opts, conf, tmp, focus=[], ignore=[]): """compare dotfiles and return True if all identical""" dotfiles = conf.get_dotfiles(opts['profile']) if dotfiles == []: @@ -188,7 +188,7 @@ def compare(opts, conf, tmp, focus=None, ignore=[]): same = True selected = dotfiles if focus: - selected = _select(focus.replace(' ', '').split(','), dotfiles) + selected = _select(focus, dotfiles) if len(selected) < 1: return False @@ -393,7 +393,7 @@ def main(): # compare local dotfiles with dotfiles stored in dotdrop tmp = get_tmpdir() opts['dopts'] = args['--dopts'] - ret = compare(opts, conf, tmp, focus=args['--files'], + ret = compare(opts, conf, tmp, focus=args['--file'], ignore=args['--ignore']) if os.listdir(tmp): LOG.raw('\ntemporary files available under {}'.format(tmp))