-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
37 lines (28 loc) · 1.26 KB
/
main.py
File metadata and controls
37 lines (28 loc) · 1.26 KB
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
import os
import pyperclip
import yaml
from pick import pick
# ─── Algorithm ────────────────────────────────────────────────────────────────
def main():
# Language Selection
os.system('cls' if os.name == 'nt' else 'clear')
title = 'Select your commit language'
options = [template[:-5] for template in os.listdir('templates')]
option, _ = pick(options, title, indicator='>> ')
# Commit Type
with open(f'templates/{option}.yaml', 'r', encoding='utf-8') as f:
templates = yaml.safe_load(f)
title = 'Select a commit type'
options = list(templates.keys())
option, _ = pick(options, title, indicator='>> ')
# Description
os.system('cls' if os.name == 'nt' else 'clear')
description = input(
f'Enter a short description (if needed) of your {templates[option]["id"]} commit.\n[Description]: '
)
commit_title = f'{templates[option]["title"]}: {description}' if description != '' else templates[
option]["title"]
pyperclip.copy(commit_title)
print('\n Commit title copied to clipboard.')
if __name__ == '__main__':
main()