aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Jon Bernard <jbernard@tuxion.com> 2011-08-28 08:37:01 -0400
committerGravatar Jon Bernard <jbernard@tuxion.com> 2011-08-28 08:37:01 -0400
commit6d113a55ea3310d0ca17a36aeef594b82e52f65c (patch)
treef697bec6a1c5c34e1701de2880e0d48ec7c13000
parent81778bbba7d3a7bc230de8420f9d453a7fefbdd5 (diff)
downloaddotfiles-6d113a55ea3310d0ca17a36aeef594b82e52f65c.tar.gz
dotfiles-6d113a55ea3310d0ca17a36aeef594b82e52f65c.tar.bz2
dotfiles-6d113a55ea3310d0ca17a36aeef594b82e52f65c.zip
Fix repository path handling
Previously, fully qualified paths and ~/ paths were properly expanded but not a directory in your current working directory. Now you can specify something like '-R myrepo' and 'myrepo' will be expanded to $PWD/myrepo.
-rw-r--r--dotfiles/cli.py17
1 files changed, 9 insertions, 8 deletions
diff --git a/dotfiles/cli.py b/dotfiles/cli.py
index d00788e..b77fb95 100644
--- a/dotfiles/cli.py
+++ b/dotfiles/cli.py
@@ -11,7 +11,7 @@ from . import core
import ConfigParser
from optparse import OptionParser, OptionGroup
-DEFAULT_REPO = "~/Dotfiles"
+DEFAULT_REPO = os.path.expanduser('~/Dotfiles')
def parse_args():
@@ -96,7 +96,7 @@ def main():
if 'dotfiles' in parser.sections():
if not opts.repo and parser.get('dotfiles', 'repository'):
- opts.repo = os.path.expanduser(parser.get('dotfiles', 'repository'))
+ opts.repo = parser.get('dotfiles', 'repository')
if opts.action == 'move':
# TODO: update the configuration file after the move
print 'Remember to update the repository location ' \
@@ -112,17 +112,17 @@ def main():
opts.externals = eval(parser.get('dotfiles', 'externals'))
if not opts.repo:
- opts.repo = os.path.expanduser(DEFAULT_REPO)
+ opts.repo = DEFAULT_REPO
+
+ opts.repo = os.path.realpath(os.path.expanduser(opts.repo))
if not opts.prefix:
opts.prefix = ''
if not os.path.exists(opts.repo):
- if opts.repo == os.path.expanduser(DEFAULT_REPO):
- print "Error: Could not find dotfiles repository \"%s\"" % DEFAULT_REPO
+ print 'Error: Could not find dotfiles repository \"%s\"' % (opts.repo)
+ if opts.repo == DEFAULT_REPO:
missing_default_repo()
- else:
- print "Error: Could not find dotfiles repository \"%s\"" % opts.repo
exit(-1)
if not opts.action:
@@ -158,7 +158,8 @@ def missing_default_repo():
print """
If this is your first time running dotfiles, you must first create
-a repository. By default, dotfiles will look for '{0}'. Something like:
+a repository. By default, dotfiles will look for '{0}'.
+Something like:
$ mkdir {0}