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)