-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate_til_commit.py
More file actions
64 lines (54 loc) Β· 2.08 KB
/
generate_til_commit.py
File metadata and controls
64 lines (54 loc) Β· 2.08 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
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
import os
import sys
import subprocess
from datetime import datetime
# μΉ΄ν
κ³ λ¦¬λ³ μ±ν° λλ μ λͺ© 리μ€νΈ (νμ μ νμ₯ κ°λ₯)
clean_code_chapters = {
1: "κΉ¨λν μ½λ",
2: "μλ―Έ μλ μ΄λ¦",
3: "ν¨μ",
4: "μ£Όμ",
5: "νμ λ§μΆκΈ°",
6: "κ°μ²΄μ μλ£κ΅¬μ‘°",
7: "μ€λ₯ μ²λ¦¬",
8: "κ²½κ³",
9: "λ¨μ ν
μ€νΈ",
10: "ν΄λμ€",
11: "μμ€ν
",
12: "μ°½λ°μ±",
13: "λμμ±",
14: "μ μ§μ μΈ κ°μ ",
15: "Junit λ€μ¬λ€λ³΄κΈ°",
16: "κΉ¨λν μ½λ",
17: "λΆλ‘: λμ μ½λ μ¬λ‘",
}
def kebab_case(text):
return text.replace(' ', '-').replace('/', '').replace(':', '').lower()
def create_markdown_file(filepath, title):
if not os.path.exists(filepath):
with open(filepath, "w", encoding="utf-8") as f:
f.write(f"# {title}\n\n")
f.write(f"> π
μμ±μΌ: {datetime.now().strftime('%Y-%m-%d')}\n\n")
f.write("## π ν΅μ¬ μμ½\n\n- \n\n## π μμ μ½λ\n\n```js\n// μμ\n```\n\n## π λλ μ \n\n- ")
if __name__ == "__main__":
if len(sys.argv) != 3:
print("μ¬μ©λ²: python generate_til_commit.py <μΉ΄ν
κ³ λ¦¬> <μ±ν°λ²νΈ λλ νμΌμ΄λ¦>")
sys.exit(1)
category = sys.argv[1].lower()
identifier = sys.argv[2]
try:
if category == "clean-code" and identifier.isdigit():
chapter_num = int(identifier)
title = f"{chapter_num}μ₯ {clean_code_chapters[chapter_num]}"
filename = f"{chapter_num:02d}_{kebab_case(clean_code_chapters[chapter_num])}.md"
else:
title = identifier.replace("-", " ").title()
filename = f"{kebab_case(identifier)}.md"
filepath = os.path.join(category, filename)
os.makedirs(os.path.dirname(filepath), exist_ok=True)
create_markdown_file(filepath, title)
print(f"β
νμΌ μμ± λ° μ»€λ° μλ£!")
print(f"π νμΌ κ²½λ‘: {filepath}")
print(f"π λ¬Έμ μ λͺ©: {title}")
except Exception as e:
print(f"β μ€λ₯: {e}")