From 8a32a80480ed7ba541bef623380d21b32b9f0f0d Mon Sep 17 00:00:00 2001 From: Martin Rey Date: Thu, 9 Jul 2020 15:11:26 +0200 Subject: [PATCH] [core] Change OptionParser to ArgumentParser --- COPYING | 1 + kibicara/config.py | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/COPYING b/COPYING index 4b75eb5..b5133de 100644 --- a/COPYING +++ b/COPYING @@ -1,6 +1,7 @@ Copyright (C) 2020 by Thomas Lindner Copyright (C) 2020 by Cathy Hu Copyright (C) 2020 by Christian +Copyright (C) 2020 by Martin Rey Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. diff --git a/kibicara/config.py b/kibicara/config.py index bbf1ab7..9459940 100644 --- a/kibicara/config.py +++ b/kibicara/config.py @@ -1,9 +1,10 @@ # Copyright (C) 2020 by Thomas Lindner # Copyright (C) 2020 by Cathy Hu +# Copyright (C) 2020 by Martin Rey # # SPDX-License-Identifier: 0BSD -from optparse import OptionParser +from argparse import ArgumentParser from pytoml import load @@ -13,12 +14,18 @@ config = { 'root_url': 'http://localhost:8000/', } -parser = OptionParser() -parser.add_option('-f', dest='configfile', default='/etc/kibicara.conf') -(option, args) = parser.parse_args() +parser = ArgumentParser() +parser.add_argument( + '-f', + '--config', + dest='configfile', + default='/etc/kibicara.conf', + help='path to config file', +) +args = parser.parse_args() try: - with open(option.configfile) as configfile: + with open(args.configfile) as configfile: config.update(load(configfile)) except FileNotFoundError: # run with default config