From 0b5c55be1b0082e8f532b4435addcd925f9ad324 Mon Sep 17 00:00:00 2001 From: "louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13" Date: Thu, 8 Jul 2010 01:30:51 +0000 Subject: add a -f option, we can specify a file to open instead of the default one. We then can have various different configuration and choose between them --- src/config.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/config.py b/src/config.py index 1b9ba287..9e067418 100644 --- a/src/config.py +++ b/src/config.py @@ -26,6 +26,7 @@ from/to the config file from ConfigParser import RawConfigParser, NoOptionError from os import environ, makedirs from shutil import copy2 +import argparse class Config(RawConfigParser): """ @@ -106,6 +107,8 @@ class Config(RawConfigParser): RawConfigParser.set(self, self.defsection, option, value) self.save() + import argparse + # creates the configuration directory if it doesn't exist # and copy the default config in it CONFIG_HOME = environ.get("XDG_CONFIG_HOME") @@ -118,4 +121,8 @@ try: except OSError: pass -config = Config(CONFIG_PATH+'poezio.cfg') +parser = argparse.ArgumentParser(prog="poezio", description='An XMPP ncurses client.') +parser.add_argument('-f', '--file', default=CONFIG_PATH+'poezio.cfg', help='the config file you want to use', metavar="FILE") +args = parser.parse_args() + +config = Config(args.file) -- cgit v1.2.3