From 9e842e8021d7e9fa468ae185436c05c975c7ccbc Mon Sep 17 00:00:00 2001 From: Dexoron Date: Thu, 12 Feb 2026 10:18:13 +0800 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=B5=D1=80=D0=B5=D0=B8=D0=BC=D0=B5?= =?UTF-8?q?=D0=BD=D0=BE=D0=B2=D0=B0=D0=BB=20update=20=D0=B2=20flag=5Fupdat?= =?UTF-8?q?e.=20=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20utils/text.py?= =?UTF-8?q?=20=D0=B4=D0=BB=D1=8F=20=D0=B2=D1=8B=D0=B2=D0=BE=D0=B4=D0=B0=20?= =?UTF-8?q?=D1=81=D0=BE=D0=BE=D0=B1=D1=89=D0=B5=D0=BD=D0=B8=D0=B9=20=D1=81?= =?UTF-8?q?=20=D1=86=D0=B2=D0=B5=D1=82=D0=BE=D0=BC.=20=D0=9E=D0=B1=D0=BD?= =?UTF-8?q?=D0=BE=D0=B2=D0=B8=D0=BB=20=D0=B2=D1=8B=D0=B2=D0=BE=D0=B4=20--h?= =?UTF-8?q?elp,=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20=D1=86?= =?UTF-8?q?=D0=B2=D0=B5=D1=82=D0=B0,=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2?= =?UTF-8?q?=D0=B8=D0=BB=20=D1=84=D0=BB=D0=B0=D0=B3=20--version,=20=D1=87?= =?UTF-8?q?=D1=82=D0=BE=20=D0=B1=D1=8B=20=D0=BF=D0=BE=D0=BA=D0=B0=D0=B7?= =?UTF-8?q?=D0=B0=D1=82=D1=8C=20=D0=B2=D0=B5=D1=80=D1=81=D0=B8=D1=8E=20dcr?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/dcr/cli/__init__.py | 4 +-- src/dcr/cli/{update.py => flag_update.py} | 2 +- src/dcr/cli/help.py | 24 ++++++++------ src/dcr/config.py | 2 ++ src/dcr/main.py | 5 ++- src/dcr/utils/text.py | 40 +++++++++++++++++++++++ 6 files changed, 63 insertions(+), 14 deletions(-) rename src/dcr/cli/{update.py => flag_update.py} (93%) create mode 100644 src/dcr/utils/text.py diff --git a/src/dcr/cli/__init__.py b/src/dcr/cli/__init__.py index de59894..f7ee317 100644 --- a/src/dcr/cli/__init__.py +++ b/src/dcr/cli/__init__.py @@ -4,7 +4,7 @@ from .new import new from .run import run from .build import build from .clean import clean -from .update import update +from .flag_update import flag_update __all__ = [ @@ -14,5 +14,5 @@ __all__ = [ "run", "build", "clean", - "update", + "flag_update", ] diff --git a/src/dcr/cli/update.py b/src/dcr/cli/flag_update.py similarity index 93% rename from src/dcr/cli/update.py rename to src/dcr/cli/flag_update.py index f6e7803..4a6aa54 100644 --- a/src/dcr/cli/update.py +++ b/src/dcr/cli/flag_update.py @@ -3,7 +3,7 @@ import shutil import subprocess -def update(args: list[str] | None = None) -> int: +def flag_update(args: list[str] | None = None) -> int: if args and len(args) > 0: print("Ошибка: команда не поддежривает аргументы") return 1 diff --git a/src/dcr/cli/help.py b/src/dcr/cli/help.py index 693fdd1..eeceba6 100644 --- a/src/dcr/cli/help.py +++ b/src/dcr/cli/help.py @@ -1,3 +1,6 @@ +from ..utils.text import colored, BRIGHT_GREEN, BRIGHT_CYAN, BOLD + + def help() -> int: print( "\n".join( @@ -5,29 +8,30 @@ def help() -> int: "DCR (Dexoron Cargo Realization)", "Менеджер C-проектов, вдохновленный Cargo.", "", - "ИСПОЛЬЗОВАНИЕ:", - " dcr <команда> [опции]", + colored("ИСПОЛЬЗОВАНИЕ:", BRIGHT_GREEN + BOLD), + colored(" dcr <команда> [опции]", BRIGHT_CYAN + BOLD), "", - "КОМАНДЫ:", + colored("КОМАНДЫ:", BRIGHT_GREEN + BOLD), " new Создать новый проект", " init Инициализировать текущую директорию как проект", " build [--profile] Собрать проект (по умолчанию: --debug)", " run [--profile] Собрать и запустить (по умолчанию: --debug)", " clean Удалить директорию target", - "ФЛАГИ:", + colored("ФЛАГИ:", BRIGHT_GREEN + BOLD), " --help Показать справку по команде", " --update Обновить dcr до актуальной версии", + " --version Показать версию dcr", "", - "ОПЦИИ:", + colored("ОПЦИИ:", BRIGHT_GREEN + BOLD), " --debug Сборка с профилем debug", " --release Сборка с профилем release", "", - "ПРИМЕРЫ:", - " dcr new hello", - " dcr build --release", - " dcr run --debug", + colored("ПРИМЕРЫ:", BRIGHT_GREEN + BOLD), + colored(" dcr new hello", BRIGHT_CYAN + BOLD), + colored(" dcr build --release", BRIGHT_CYAN + BOLD), + colored(" dcr run --debug", BRIGHT_CYAN + BOLD), "", - "ПОДСКАЗКА:", + colored("ПОДСКАЗКА:", BRIGHT_GREEN + BOLD), " Запусти 'dcr <команда> --help' для справки по команде.", ] ) diff --git a/src/dcr/config.py b/src/dcr/config.py index a3c835c..20aebf5 100644 --- a/src/dcr/config.py +++ b/src/dcr/config.py @@ -40,3 +40,5 @@ flags: dict[str, list[str]] = { "release": ["-O3", "-DNDEBUG", "-march=native"], "debug": ["-O0", "-g", "-Wall", "-Wextra", "-fno-omit-frame-pointer", "-DDEBUG"], } + +VERSION = "v0.1.1" \ No newline at end of file diff --git a/src/dcr/main.py b/src/dcr/main.py index 93d4dad..00a110e 100644 --- a/src/dcr/main.py +++ b/src/dcr/main.py @@ -1,3 +1,4 @@ +from src.dcr.config import VERSION import dcr.cli as cli import sys @@ -21,10 +22,12 @@ def main() -> int: cli.run(args) case "clean": cli.clean(args) + case "--version": + print(f"dcr {VERSION} (GNU/Linux)") case "--help": cli.help() case "--update": - cli.update(args) + cli.flag_update(args) case _: print("Неизвестная команда или аргумент") diff --git a/src/dcr/utils/text.py b/src/dcr/utils/text.py new file mode 100644 index 0000000..29a38a8 --- /dev/null +++ b/src/dcr/utils/text.py @@ -0,0 +1,40 @@ +# RESET +RESET = "\033[0m" + +# TEXT STYLES +BOLD = "\033[1m" +DIM = "\033[2m" +ITALIC = "\033[3m" +UNDERLINE = "\033[4m" +BLINK = "\033[5m" +REVERSE = "\033[7m" +HIDDEN = "\033[8m" +STRIKETHROUGH = "\033[9m" + +# STANDARD COLORS (Foreground) +BLACK = "\033[30m" +RED = "\033[31m" +GREEN = "\033[32m" +YELLOW = "\033[33m" +BLUE = "\033[34m" +MAGENTA = "\033[35m" +CYAN = "\033[36m" +WHITE = "\033[37m" + +# BRIGHT COLORS +BRIGHT_BLACK = "\033[90m" +BRIGHT_RED = "\033[91m" +BRIGHT_GREEN = "\033[92m" +BRIGHT_YELLOW = "\033[93m" +BRIGHT_BLUE = "\033[94m" +BRIGHT_MAGENTA = "\033[95m" +BRIGHT_CYAN = "\033[96m" +BRIGHT_WHITE = "\033[97m" + + +def colored(msg: str, style: str) -> str: + return style + msg + RESET + + +def printc(msg: str, style: str) -> None: + print(style + msg + RESET)