syslog2irc.cli._create_arg_parser()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 16
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 16
ccs 5
cts 5
cp 1
rs 9.9
c 0
b 0
f 0
cc 1
nop 0
crap 1
1
"""
2
syslog2irc.cli
3
~~~~~~~~~~~~~~
4
5
Command line argument parsing
6
7
:Copyright: 2007-2021 Jochen Kupperschmidt
8
:License: MIT, see LICENSE for details.
9
"""
10
11 1
from __future__ import annotations
12 1
from argparse import ArgumentParser, Namespace
13 1
from pathlib import Path
14 1
from typing import Optional
15
16 1
from . import VERSION
17
18
19 1
def parse_args(args: Optional[list[str]] = None) -> Namespace:
20
    """Parse command line arguments."""
21 1
    parser = _create_arg_parser()
22 1
    return parser.parse_args(args)
23
24
25 1
def _create_arg_parser() -> ArgumentParser:
26
    """Prepare the command line arguments parser."""
27 1
    parser = ArgumentParser()
28
29 1
    parser.add_argument(
30
        '--version',
31
        action='version',
32
        version=f'syslog2IRC {VERSION}',
33
    )
34
35 1
    parser.add_argument(
36
        'config_filename',
37
        type=Path,
38
    )
39
40
    return parser
41