summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Jay Sweeney <writetojay@gmail.com> 2013-11-09 13:24:04 +1000
committerGravatar Jon Bernard <jbernard@tuxion.com> 2013-11-09 16:36:07 -0500
commit16eec288035b56874b77c542cb7cbaf80b641a89 (patch)
tree4ff167c697c151d2217ba0a5763154637f8e8330
parent02552b3c684f8fc1859af7660f345ff0c038e4f4 (diff)
downloaddotfiles-16eec288035b56874b77c542cb7cbaf80b641a89.tar.gz
dotfiles-16eec288035b56874b77c542cb7cbaf80b641a89.tar.bz2
dotfiles-16eec288035b56874b77c542cb7cbaf80b641a89.zip
Fixes #22: Ensure --force option is handed on
-rw-r--r--dotfiles/cli.py4
-rwxr-xr-xtest_dotfiles.py9
2 files changed, 12 insertions, 1 deletions
diff --git a/dotfiles/cli.py b/dotfiles/cli.py
index c0984d6..a071240 100644
--- a/dotfiles/cli.py
+++ b/dotfiles/cli.py
@@ -177,8 +177,10 @@ def parse_config(config_file):
def dispatch(dotfiles, action, force, args):
if action in ['list', 'check']:
getattr(dotfiles, action)()
- elif action in ['add', 'remove', 'sync']:
+ elif action in ['add', 'remove']:
getattr(dotfiles, action)(args)
+ elif action == 'sync':
+ getattr(dotfiles, action)(files=args, force=force)
elif action == 'move':
if len(args) > 1:
print("Error: Move cannot handle multiple targets.")
diff --git a/test_dotfiles.py b/test_dotfiles.py
index b5521d2..761496e 100755
--- a/test_dotfiles.py
+++ b/test_dotfiles.py
@@ -9,6 +9,7 @@ import tempfile
import unittest
from dotfiles import core
+from dotfiles import cli
from dotfiles.utils import is_link_to
@@ -62,6 +63,14 @@ class DotfilesTestCase(unittest.TestCase):
os.path.join(self.homedir, '.lastpass'),
'/tmp')
+ def test_dispatch(self):
+ """Test that the force option is handed on to the sync method."""
+ class MockDotfiles(object):
+ def sync(self, files=None, force=False):
+ assert bool(force)
+ dotfiles = MockDotfiles()
+ cli.dispatch(dotfiles, 'sync', True, [])
+
def test_move_repository(self):
"""Test the move() method for a Dotfiles repository."""