Completed
Pull Request — master (#59)
by Gonzalo
57s
created

parse_arguments()   B

Complexity

Conditions 2

Size

Total Lines 36

Duplication

Lines 0
Ratio 0 %

Importance

Changes 5
Bugs 0 Features 2
Metric Value
cc 2
c 5
b 0
f 2
dl 0
loc 36
rs 8.8571
1
# -*- coding: utf-8 -*-
2
# -----------------------------------------------------------------------------
3
# Copyright (c) The Spyder Development Team
4
#
5
# Licensed under the terms of the MIT License
6
# (See LICENSE.txt for details)
7
# -----------------------------------------------------------------------------
8
"""Create github labels from a text file."""
9
10
# yapf: disable
11
12
# Standard library imports
13
import argparse
14
15
# Local imports
16
from loghub.cli.common import add_common_parser_args, parse_password_check_repo
17
from loghub.core.labels import process_labels
18
19
20
# yapf: enable
21
22
23
def main():
24
    """Main script."""
25
    parse_arguments(skip=False)
26
27
28
def parse_arguments(skip=False):
29
    """Parse argument for label creator utility."""
30
    # Get command-line arguments
31
    parser = argparse.ArgumentParser()
32
33
    parser = add_common_parser_args(parser)
34
    parser.add_argument(
35
        '-a',
36
        '--action',
37
        help='Action to take',
38
        type=str,
39
        choices=['get', 'update'],
40
        default='get',
41
        nargs='?')
42
    parser.add_argument(
43
        '-f',
44
        '--filename',
45
        help='File for storing labels',
46
        type=str,
47
        default='labels.txt')
48
49
    options = parser.parse_args()
50
51
    username = options.username
52
    password = parse_password_check_repo(options)
53
54
    if not skip:
55
        process_labels(
56
            username,
57
            password,
58
            options.token,
59
            options.action,
60
            options.repository,
61
            options.filename, )
62
63
    return options
64
65
66
if __name__ == '__main__':
67
    main()
68