Passed
Push — main ( c049b2...7b4205 )
by Jochen
01:43
created

weitersager.cli   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Test Coverage

Coverage 77.78%

Importance

Changes 0
Metric Value
eloc 20
dl 0
loc 40
ccs 14
cts 18
cp 0.7778
rs 10
c 0
b 0
f 0
wmc 2

2 Functions

Rating   Name   Duplication   Size   Complexity  
A parse_args() 0 8 1
A main() 0 5 1
1
"""
2
weitersager.cli
3
~~~~~~~~~~~~~~~
4
5
Command line entry point
6
7
:Copyright: 2007-2021 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 . import VERSION
17 1
from .config import load_config
18 1
from .processor import start
19
20
21 1
def parse_args(args: List[str]) -> Namespace:
22
    """Parse command line arguments."""
23 1
    parser = ArgumentParser()
24 1
    parser.add_argument(
25
        '--version', action='version', version=f'Weitersager {VERSION}'
26
    )
27 1
    parser.add_argument('config_filename', type=Path)
28 1
    return parser.parse_args(args)
29
30
31 1
def main() -> None:
32
    """Load the configuration file, start the IRC bot and HTTP listen server."""
33
    namespace = parse_args(sys.argv[1:])
34
    config = load_config(namespace.config_filename)
35
    start(config)
36
37
38 1
if __name__ == '__main__':
39
    main()
40