-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.py
More file actions
50 lines (40 loc) · 1.5 KB
/
cli.py
File metadata and controls
50 lines (40 loc) · 1.5 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
import argparse
def parse_args():
parser = argparse.ArgumentParser(
description="Code Extractor: утилита для экспорта структуры и содержимого проекта"
)
parser.add_argument(
"--root",
type=str,
help="Путь к корню проекта (переопределяет ROOT_DIR из .env)"
)
parser.add_argument(
"--safe",
type=str,
choices=["true", "false"],
help="Включить/выключить SAFE_MODE (переопределяет SAFE_MODE из .env)"
)
parser.add_argument(
"--max-size",
type=str,
help="Максимальный размер файла для чтения (например: 2MB, 500KB, 1000000)"
)
parser.add_argument(
"--encoding",
type=str,
help="Кодировка файлов (по умолчанию utf-8)"
)
parser.add_argument(
"--exclude",
type=str,
help="Список папок для исключения через запятую"
)
return parser.parse_args()
def parse_size(value: str) -> int:
"""Парсим значения с суффиксами MB/KB/B"""
units = {"kb": 1024, "mb": 1024 * 1024, "b": 1}
value = value.strip().lower()
for unit, factor in units.items():
if value.endswith(unit):
return int(float(value.replace(unit, "")) * factor)
return int(value) # если просто число