From 35dd8812ad42570599c6aacbb785821160ee0101 Mon Sep 17 00:00:00 2001 From: Dexoron Date: Thu, 12 Feb 2026 09:46:52 +0800 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B0=20=D0=BA=D0=BE=D0=BC=D0=B0=D0=BD=D0=B4=D0=B0=20?= =?UTF-8?q?=D0=BE=D0=B1=D0=BD=D0=BE=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F=20?= =?UTF-8?q?=D0=B8=20=D0=BE=D0=B1=D0=BD=D0=BE=D0=B2=D0=BB=D0=B5=D0=BD=D0=BE?= =?UTF-8?q?=20=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BE=D1=87=D0=BD=D0=BE=D0=B5?= =?UTF-8?q?=20=D1=81=D0=BE=D0=BE=D0=B1=D1=89=D0=B5=D0=BD=D0=B8=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/dcr/cli/__init__.py | 2 ++ src/dcr/cli/help.py | 4 +++- src/dcr/cli/update.py | 23 +++++++++++++++++++++++ src/dcr/main.py | 8 ++++++-- 4 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 src/dcr/cli/update.py diff --git a/src/dcr/cli/__init__.py b/src/dcr/cli/__init__.py index f450ff1..de59894 100644 --- a/src/dcr/cli/__init__.py +++ b/src/dcr/cli/__init__.py @@ -4,6 +4,7 @@ from .new import new from .run import run from .build import build from .clean import clean +from .update import update __all__ = [ @@ -13,4 +14,5 @@ __all__ = [ "run", "build", "clean", + "update", ] diff --git a/src/dcr/cli/help.py b/src/dcr/cli/help.py index 8d2231f..693fdd1 100644 --- a/src/dcr/cli/help.py +++ b/src/dcr/cli/help.py @@ -14,7 +14,9 @@ def help() -> int: " build [--profile] Собрать проект (по умолчанию: --debug)", " run [--profile] Собрать и запустить (по умолчанию: --debug)", " clean Удалить директорию target", - " help Показать эту справку", + "ФЛАГИ:", + " --help Показать справку по команде", + " --update Обновить dcr до актуальной версии", "", "ОПЦИИ:", " --debug Сборка с профилем debug", diff --git a/src/dcr/cli/update.py b/src/dcr/cli/update.py new file mode 100644 index 0000000..f6e7803 --- /dev/null +++ b/src/dcr/cli/update.py @@ -0,0 +1,23 @@ +import platform +import shutil +import subprocess + + +def update(args: list[str] | None = None) -> int: + if args and len(args) > 0: + print("Ошибка: команда не поддежривает аргументы") + return 1 + if platform.system() != "Linux": + print("Ошибка: обновление поддерживается только на Linux") + return 1 + if shutil.which("curl") is None: + print("Ошибка: не найден curl") + return 1 + try: + subprocess.run( + ["bash", "-c", "curl -fsSL dcr.zov.tatar | bash"], check=True + ) + return 0 + except subprocess.CalledProcessError: + print("Ошибка: не удалось выполнить обновление") + return 1 diff --git a/src/dcr/main.py b/src/dcr/main.py index 9e308c0..93d4dad 100644 --- a/src/dcr/main.py +++ b/src/dcr/main.py @@ -3,7 +3,7 @@ import sys def main() -> int: - if len(sys.argv) < 2 or sys.argv[1] == "--help": + if len(sys.argv) < 2: cli.help() return 0 @@ -21,8 +21,12 @@ def main() -> int: cli.run(args) case "clean": cli.clean(args) + case "--help": + cli.help() + case "--update": + cli.update(args) case _: - print("Unknown command") + print("Неизвестная команда или аргумент") return 0