Completed
Push — main ( 25807a...2ed45a )
by Jochen
01:37
created

weitersager.cli.parse_args()   A

Complexity

Conditions 1

Size

Total Lines 5
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 4
nop 1
dl 0
loc 5
ccs 4
cts 4
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
"""
2
weitersager.cli
3
~~~~~~~~~~~~~~~
4
5
Command line entry point
6
7
:Copyright: 2007-2020 Jochen Kupperschmidt
8
:License: MIT, see LICENSE for details.
9
"""
10
11 1
from argparse import ArgumentParser, Namespace
12 1
from pathlib import Path
13 1
import sys
14 1
from typing import List
15
16 1
from .config import load_config
17 1
from .processor import start
18
19
20 1
def parse_args(args: List[str]) -> Namespace:
21
    """Parse command line arguments."""
22 1
    parser = ArgumentParser(prog='weitersager')
23 1
    parser.add_argument('config_filename', type=Path)
24 1
    return parser.parse_args(args)
25
26
27 1
def main() -> None:
28
    """Load the configuration file, start the IRC bot and HTTP listen server."""
29
    namespace = parse_args(sys.argv[1:])
30
    config = load_config(namespace.config_filename)
31
    start(config)
32
33
34 1
if __name__ == '__main__':
35
    main()
36