|
14 | 14 | # utils imports |
15 | 15 | from utils import parser_cli |
16 | 16 | from utils import create_file |
| 17 | +from utils import debug |
17 | 18 |
|
18 | 19 |
|
| 20 | +def main(debug_mode=False): |
| 21 | + file_path = Path('commiter.yml') |
| 22 | + debug('file_path', file_path, debug_mode) |
| 23 | + if file_path.is_file(): |
| 24 | + with open(str(file_path), 'r') as stream: |
| 25 | + try: |
| 26 | + config = safe_load(stream) |
| 27 | + debug('convention from file', config['convention'], debug_mode) |
| 28 | + if config['convention'] is not None: |
| 29 | + convention = str(config['convention']).lower() |
| 30 | + else: |
| 31 | + convention = 'none' |
| 32 | + if convention == 'angular' or convention == 'karma': |
| 33 | + print('You are using the %s convention' % convention) |
| 34 | + angular_convention(args.co_author) |
| 35 | + elif convention == 'changelog': |
| 36 | + print('You are using the %s convention' % convention) |
| 37 | + changelog_convention(args.co_author) |
| 38 | + elif convention == 'symphony': |
| 39 | + print('You are using the %s convention' % convention) |
| 40 | + symphony_convention(args.co_author) |
| 41 | + elif convention == 'none': |
| 42 | + just_message(args.co_author) |
| 43 | + except YAMLError as exc: |
| 44 | + print(exc) |
| 45 | + |
| 46 | + elif args.convention is not '': |
| 47 | + convention = str(args.convention) |
| 48 | + debug('convention flag', convention, debug_mode) |
| 49 | + if convention == 'angular' or convention == 'karma': |
| 50 | + angular_convention(args.co_author) |
| 51 | + create_file(convention, args.no_file) |
| 52 | + elif convention == 'changelog': |
| 53 | + changelog_convention(args.co_author) |
| 54 | + create_file(convention, args.no_file) |
| 55 | + elif convention == 'symphony': |
| 56 | + symphony_convention(args.co_author) |
| 57 | + create_file(convention, args.no_file) |
| 58 | + elif convention == 'message': |
| 59 | + just_message(convention) |
| 60 | + create_file('none', args.no_file) |
| 61 | + |
| 62 | + else: |
| 63 | + debug('parser full return', parser.parse_args(), debug_mode) |
| 64 | + parser.print_help() |
| 65 | + |
| 66 | + |
| 67 | +debug_option = False |
19 | 68 | parser = parser_cli() |
20 | 69 | args = parser.parse_args() |
21 | | - |
22 | | -file_path = Path('commiter.yml') |
23 | | -if file_path.is_file(): |
24 | | - with open(str(file_path), 'r') as stream: |
25 | | - try: |
26 | | - config = safe_load(stream) |
27 | | - if config['convention'] is not None: |
28 | | - convention = str(config['convention']).lower() |
29 | | - else: |
30 | | - convention = 'none' |
31 | | - if convention == 'angular' or convention == 'karma': |
32 | | - print('You are using the %s convention' % convention) |
33 | | - angular_convention(args.co_author) |
34 | | - elif convention == 'changelog': |
35 | | - print('You are using the %s convention' % convention) |
36 | | - changelog_convention(args.co_author) |
37 | | - elif convention == 'symphony': |
38 | | - print('You are using the %s convention' % convention) |
39 | | - symphony_convention(args.co_author) |
40 | | - elif convention == 'none': |
41 | | - just_message(args.co_author) |
42 | | - except YAMLError as exc: |
43 | | - print(exc) |
44 | | - |
45 | | -elif args.convention is not '': |
46 | | - convention = str(args.convention) |
47 | | - if convention == 'angular' or convention == 'karma': |
48 | | - angular_convention(args.co_author) |
49 | | - create_file(convention, args.no_file) |
50 | | - elif convention == 'changelog': |
51 | | - changelog_convention(args.co_author) |
52 | | - create_file(convention, args.no_file) |
53 | | - elif convention == 'symphony': |
54 | | - symphony_convention(args.co_author) |
55 | | - create_file(convention, args.no_file) |
56 | | - elif convention == 'message': |
57 | | - just_message(convention) |
58 | | - create_file('none', args.no_file) |
59 | | - |
60 | | -else: |
61 | | - parser.print_help() |
| 70 | +debug('args variable', args, debug_option) |
| 71 | +main(debug_option) |
0 commit comments