From 15c5d3abf2b2fe9801555a76ca602418123afd43 Mon Sep 17 00:00:00 2001 From: David Trail Date: Tue, 9 Apr 2013 10:08:20 +0100 Subject: [PATCH] Optional -c / --config option with argparse for seperate config files. --- shreddit | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/shreddit b/shreddit index 6be20f1..e5337f8 100755 --- a/shreddit +++ b/shreddit @@ -2,10 +2,18 @@ import praw import ConfigParser +import argparse from datetime import datetime, timedelta +parser = argparse.ArgumentParser() +parser.add_argument('-c', '--config', help="config file to use instead of shreddit.cfg") +args = parser.parse_args() + config = ConfigParser.RawConfigParser() -config.read('shreddit.cfg') +if args.config: + config.read(args.config) +else: + config.read('shreddit.cfg') hours = config.getint('main', 'hours') whitelist = config.get('main', 'whitelist')