-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtext_utils.py
74 lines (58 loc) · 1.66 KB
/
text_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
74
from .colors import RESET
from .colors import DEBUG_COLOR
from .colors import INPUT_COLOR
from .colors import NOTIFY_COLOR
from .colors import HELP
def get_text():
"""
Gets the input for both tag and message.
"""
tag = str(input(INPUT_COLOR + 'type the tag: ' + RESET))
msg = str(input(INPUT_COLOR + 'type the commit message: ' + RESET)).lower()
return tag, msg
def get_context():
"""
Gets the input for the commit context and formats it to lowercase.
"""
context = str(input(INPUT_COLOR + 'type the context: ' + RESET) or '')
context.lower()
return context
def sanitize_as_empty_string(string):
"""
Checks if arg is None and returns it as an empty string.
"""
if string is None:
return ''
return string
def notify(message):
"""
Colored formatted print for notifications.
"""
print(NOTIFY_COLOR + str(message) + RESET)
def debug(message, value, show=False):
"""
Colored formatted print for debugging.
"""
if show:
mid = 'DEBUG: ' + str(message) + ' ~> ' + str(value)
print(DEBUG_COLOR + mid + RESET)
def print_help(message):
"""
Colored formatted print for help menus.
"""
print(HELP + str(message) + RESET)
def handle_tag_message_args(tag='', message=''):
"""
Checks if args are empty strings, if so it calls the get_text function.
"""
if tag + message is not '':
return tag, message
return get_text()
def handle_context_arg(context=''):
"""
Checks if context is empty and if it is calls a input function to get the
context.
"""
if context is not '':
return context
return get_context()