Files

37 lines
1.4 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env python3
"""Local administrator-only command-line deployment / rollback.
This CLI is NOT exposed via MCP or Flask.
"""
from __future__ import annotations
import argparse
import os
import sys
from pathlib import Path
ROOT=Path(__file__).resolve().parents[1]
sys.path.insert(0,str(ROOT))
from services import alfred_developer_core as dev
def main():
p=argparse.ArgumentParser(description='Alfred Developer: déploiement local contrôlé')
p.add_argument('action',choices=['deploy','rollback'])
p.add_argument('id')
p.add_argument('--apply',action='store_true',help='Appliquer réellement ; sinon simulation')
args=p.parse_args()
if args.apply and os.geteuid()!=0:
p.error('Seul un administrateur root local peut appliquer un changement.')
try:
if args.action=='deploy':out=dev.deploy(args.id,apply=args.apply)
else:out=dev.rollback(args.id,apply=args.apply)
print(out)
if args.apply and out.get('requires_restart'):
print('Fichiers Python modifiés : redémarrer alfred.service puis vérifier la santé du service.')
elif args.apply:
print('Actualise ton navigateur (Ctrl+F5) ; vérifier l’interface avant de conserver le changement.')
return 0
except (ValueError,OSError,RuntimeError) as e:
print('OPÉRATION REFUSÉE :',e,file=sys.stderr);return 1
if __name__=='__main__':raise SystemExit(main())