args.py 1.08 KB
Newer Older
1 2 3 4 5 6
"""
Module related to the argument parsing

There is a fallback to the deprecated optparse if argparse is not found
"""
from os import path
7
from argparse import ArgumentParser, SUPPRESS
8 9 10 11 12

def parse_args(CONFIG_PATH=''):
    """
    Parse the arguments from the command line
    """
13 14 15
    parser = ArgumentParser('poezio')
    parser.add_argument("-c", "--check-config", dest="check_config",
                        action='store_true',
16
                        help='Check the config file')
17
    parser.add_argument("-d", "--debug", dest="debug",
18
                        help="The file where debug will be written",
19
                        metavar="DEBUG_FILE")
20 21
    parser.add_argument("-f", "--file", dest="filename",
                        default=path.join(CONFIG_PATH, 'poezio.cfg'),
22
                        help="The config file you want to use",
23
                        metavar="CONFIG_FILE")
24 25
    parser.add_argument("-v", "--version", dest="version",
                        help=SUPPRESS, metavar="VERSION",
mathieui's avatar
mathieui committed
26
                        default="0.10-dev")
27
    options = parser.parse_args()
28
    return options