diff options
author | Linus Nordberg <linus@nordberg.se> | 2022-07-21 13:41:34 +0200 |
---|---|---|
committer | Linus Nordberg <linus@nordberg.se> | 2022-07-21 13:42:33 +0200 |
commit | d7cc4c8089254fa22ea8ff7e256cfdeae82c868d (patch) | |
tree | 956618e2ca67c3740612a79cd0ebb3a3d4ba4315 | |
parent | 4b3658ff1fc7a9877552bd006fc09b5e25f83854 (diff) |
Add command line argument --config (-f)
-rwxr-xr-x | main.py | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -46,12 +46,15 @@ if __name__ == "__main__": parser.add_argument('-v', action="store_true", help="Print verbose debugging information to the logfile") parser.add_argument('-d', action="store_true", help="Print verbose debugging information to stderr") parser.add_argument('--nomail', action="store_true", help="Do everything except sending email") + parser.add_argument('-f', '--config', help="Configuration file (default: settings.cfg)") args = parser.parse_args() config = configparser.ConfigParser() - configfile = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'settings.cfg') - config.read(configfile) + if args.config: + config.read(args.config) + else: + config.read(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'settings.cfg')) if args.nomail: config.set('email', 'nomail', "True") |