summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2015-02-16 20:32:26 +0100
committerFlorent Le Coz <louiz@louiz.org>2015-02-16 20:33:54 +0100
commita657d472cd164d4a0134e0bf16ed18dc0349d277 (patch)
treec8e0f3f2ac86f7cbf9eec605736f890f982ed98a /src
parentca21aa7bb02ffa2ac9dceb7d1be448ce9882d920 (diff)
downloadpoezio-a657d472cd164d4a0134e0bf16ed18dc0349d277.tar.gz
poezio-a657d472cd164d4a0134e0bf16ed18dc0349d277.tar.bz2
poezio-a657d472cd164d4a0134e0bf16ed18dc0349d277.tar.xz
poezio-a657d472cd164d4a0134e0bf16ed18dc0349d277.zip
Remove the optparse backward compatibility, and fix the --version feature
Diffstat (limited to 'src')
-rw-r--r--src/args.py42
1 files changed, 12 insertions, 30 deletions
diff --git a/src/args.py b/src/args.py
index 030f7212..95acbfd6 100644
--- a/src/args.py
+++ b/src/args.py
@@ -5,39 +5,21 @@ There is a fallback to the deprecated optparse if argparse is not found
"""
from gettext import gettext as _
from os import path
+from argparse import ArgumentParser, SUPPRESS
def parse_args(CONFIG_PATH=''):
"""
Parse the arguments from the command line
"""
- try:
- from argparse import ArgumentParser, SUPPRESS
- except ImportError:
- from optparse import OptionParser
- from optparse import SUPPRESS_HELP as SUPPRESS
- parser = OptionParser()
- parser.add_option("-f", "--file", dest="filename",
- default=path.join(CONFIG_PATH, 'poezio.cfg'),
- help=_("The config file you want to use"),
- metavar="CONFIG_FILE")
- parser.add_option("-d", "--debug", dest="debug",
- help=_("The file where debug will be written"),
- metavar="DEBUG_FILE")
- parser.add_option("-v", "--version", dest="version",
- help=SUPPRESS, metavar="VERSION",
- default="0.9-dev")
- (options, __) = parser.parse_args()
- else:
- parser = ArgumentParser()
- parser.add_argument("-f", "--file", dest="filename",
- default=path.join(CONFIG_PATH, 'poezio.cfg'),
- help=_("The config file you want to use"),
- metavar="CONFIG_FILE")
- parser.add_argument("-d", "--debug", dest="debug",
- help=_("The file where debug will be written"),
- metavar="DEBUG_FILE")
- parser.add_argument("-v", "--version", dest="version",
- help=SUPPRESS, metavar="VERSION",
- default="0.9-dev")
- options = parser.parse_args()
+ parser = ArgumentParser()
+ parser.add_argument("-f", "--file", dest="filename",
+ default=path.join(CONFIG_PATH, 'poezio.cfg'),
+ help=_("The config file you want to use"),
+ metavar="CONFIG_FILE")
+ parser.add_argument("-d", "--debug", dest="debug",
+ help=_("The file where debug will be written"),
+ metavar="DEBUG_FILE")
+ parser.add_argument("-v", "--version", action="version",
+ version="0.9-dev")
+ options = parser.parse_args()
return options