-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathutils.py
73 lines (59 loc) · 2.09 KB
/
utils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import argparse
from yaml import dump
supported_conventions = [
"angular",
"changelog",
"symphony",
"message",
]
menu = """
What type of commit convention are you using?
default: Just the message
1: Karma/Angular
2: Conventional changelog
3: Symfony CMF
"""
def get_text(context=False):
if context:
tag = str(input("type the tag: "))
msg = str(input("type the commit message: ")).lower()
context = str(input('type the context: ')).lower()
return tag, msg, context
else:
tag = str(input("type the tag: "))
msg = str(input("type the commit message: ")).lower()
return tag, msg
def create_file(convention_name, dont_create=False):
if not dont_create:
data = dict(
convention=convention_name
)
with open('commiter.yml', 'w') as output_file:
dump(data, output_file, default_flow_style=False)
print('Successfully created the commiter file.')
def parser_cli():
desc = "A commit formatter tool to help you follow commit conventions."
help_convention = \
"""
Selects a convention to be used for the commit.
Required if there's no commiter.yml file.
"""
parser = argparse.ArgumentParser(description=desc)
parser.add_argument("--co-author",
help="Make your friend an co-author to the commit",
dest="co_author", default='')
parser.add_argument("--no-file", dest="no_file",
help="Disables the creation of a commiter.yml file",
action="store_true")
parser.add_argument("--convention", choices=supported_conventions,
dest="convention", default='', help=help_convention)
parser.add_argument('--debug', action="store_true", dest="debug",
help="Toggles debug option")
return parser
def change_if_none(string):
if string is None:
return ''
return string
def debug(message, value, show=False):
if show:
print("DEBUG-> %s: %s" % (message, value))