summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Jon Bernard <jbernard@tuxion.com> 2011-08-27 10:11:03 -0400
committerGravatar Jon Bernard <jbernard@tuxion.com> 2011-08-27 10:11:03 -0400
commitbf6ad3b0b4e7065d1ff1f3f5cdec61cba386813b (patch)
treea5f65505f04ba691a9b1c4292cc2d6077824c42d
parent142a893a006d3226d8d4caa512c8fdfffd9acb31 (diff)
downloaddotfiles-bf6ad3b0b4e7065d1ff1f3f5cdec61cba386813b.tar.gz
dotfiles-bf6ad3b0b4e7065d1ff1f3f5cdec61cba386813b.tar.bz2
dotfiles-bf6ad3b0b4e7065d1ff1f3f5cdec61cba386813b.zip
Make home directory user-definable
This paves the way for unit tests to perform operations completely within a sandboxed environment.
-rw-r--r--dotfiles/cli.py3
-rw-r--r--dotfiles/core.py4
2 files changed, 5 insertions, 2 deletions
diff --git a/dotfiles/cli.py b/dotfiles/cli.py
index 2725c06..e9cf19a 100644
--- a/dotfiles/cli.py
+++ b/dotfiles/cli.py
@@ -43,6 +43,9 @@ def parse_args():
parser.add_option("-C", "--config", type="string", dest="config",
help="set configuration file location (default is ~/.dotfilesrc)")
+ parser.add_option("-H", "--home", type="string", dest="home",
+ help="set home directory location (default is ~/)")
+
action_group = OptionGroup(parser, "Actions")
action_group.add_option("-a", "--add", action="store_const", dest="action",
diff --git a/dotfiles/core.py b/dotfiles/core.py
index 5bc472e..22cacb8 100644
--- a/dotfiles/core.py
+++ b/dotfiles/core.py
@@ -18,11 +18,11 @@ __license__ = "GPL"
class Dotfile(object):
- def __init__(self, name, target):
+ def __init__(self, name, target, home):
if name.startswith('/'):
self.name = name
else:
- self.name = os.path.expanduser('~/.%s' % name.strip('.'))
+ self.name = os.path.expanduser(home + '/.%s' % name.strip('.'))
self.basename = os.path.basename(self.name)
self.target = target.rstrip('/')
self.status = ''