From bc6bd6c777e6cc8499c29eee4576759615b5daf8 Mon Sep 17 00:00:00 2001 From: Sean Hammond Date: Fri, 30 Apr 2010 23:06:22 +0100 Subject: [PATCH] Don't require TO_DIR argument if action is TIDY, --- dotfilemanager.py | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/dotfilemanager.py b/dotfilemanager.py index b0ede0e..a5e817c 100755 --- a/dotfilemanager.py +++ b/dotfilemanager.py @@ -175,25 +175,24 @@ if __name__ == "__main__": print "FROM_DIR %s is not a directory!" % FROM_DIR print usage() sys.exit(2) - try: - TO_DIR = sys.argv[3] - except IndexError: - TO_DIR = os.path.join('~','.dotfiles') - if not os.path.isdir(TO_DIR): - print "TO_DIR %s is not a directory!" % TO_DIR - print usage() - sys.exit(2) - - TO_DIR = os.path.abspath(os.path.expanduser(TO_DIR)) FROM_DIR = os.path.abspath(os.path.expanduser(FROM_DIR)) - - if ACTION == 'link': - link(FROM_DIR,TO_DIR) - elif ACTION == 'tidy': + if ACTION == 'tidy': tidy(FROM_DIR) - elif ACTION == 'report': - link(FROM_DIR,TO_DIR,report=True) - tidy(FROM_DIR,report=True) - else: - print usage() - sys.exit(2) + else: + try: + TO_DIR = sys.argv[3] + except IndexError: + TO_DIR = os.path.join('~','.dotfiles') + if not os.path.isdir(TO_DIR): + print "TO_DIR %s is not a directory!" % TO_DIR + print usage() + sys.exit(2) + TO_DIR = os.path.abspath(os.path.expanduser(TO_DIR)) + if ACTION == 'link': + link(FROM_DIR,TO_DIR) + elif ACTION == 'report': + link(FROM_DIR,TO_DIR,report=True) + tidy(FROM_DIR,report=True) + else: + print usage() + sys.exit(2)