summaryrefslogtreecommitdiff
path: root/doc/stub/args.py
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2013-04-08 18:52:35 +0200
committermathieui <mathieui@mathieui.net>2013-04-08 18:52:35 +0200
commitbd8d38d711e15d42ac8e797723af5242e4c3f4fb (patch)
treed3ea6da641be1c7e67a3123071cb816933436502 /doc/stub/args.py
parente5f219d43edbb4b05c8890f81f2f93b90e215a10 (diff)
downloadpoezio-bd8d38d711e15d42ac8e797723af5242e4c3f4fb.tar.gz
poezio-bd8d38d711e15d42ac8e797723af5242e4c3f4fb.tar.bz2
poezio-bd8d38d711e15d42ac8e797723af5242e4c3f4fb.tar.xz
poezio-bd8d38d711e15d42ac8e797723af5242e4c3f4fb.zip
Beginning of the migration to reST documentation
Diffstat (limited to 'doc/stub/args.py')
-rw-r--r--doc/stub/args.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/doc/stub/args.py b/doc/stub/args.py
new file mode 100644
index 00000000..4691a224
--- /dev/null
+++ b/doc/stub/args.py
@@ -0,0 +1,34 @@
+"""
+Module related to the argument parsing
+
+There is a fallback to the deprecated optparse if argparse is not found
+"""
+from os import path
+
+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.8-dev")
+ (options, args) = 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.8-dev")
+ options = parser.parse_args()
+ return options