Добавлена команда обновления и обновлено справочное сообщение

This commit is contained in:
2026-02-12 09:46:52 +08:00
parent 675352afc0
commit 35dd8812ad
4 changed files with 34 additions and 3 deletions

View File

@@ -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",
]

View File

@@ -14,7 +14,9 @@ def help() -> int:
" build [--profile] Собрать проект (по умолчанию: --debug)",
" run [--profile] Собрать и запустить (по умолчанию: --debug)",
" clean Удалить директорию target",
" help Показать эту справку",
"ФЛАГИ:",
" --help Показать справку по команде",
" --update Обновить dcr до актуальной версии",
"",
"ОПЦИИ:",
" --debug Сборка с профилем debug",

23
src/dcr/cli/update.py Normal file
View File

@@ -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

View File

@@ -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