Les choses sérieuses commencent
This commit is contained in:
parent
7a9fe18463
commit
c63f62721b
41 changed files with 1270 additions and 0 deletions
54
erminig/cli/evezh.py
Normal file
54
erminig/cli/evezh.py
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
import argparse
|
||||
import json
|
||||
from erminig.controllers.evezh import check
|
||||
from erminig.models.db import init_db
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description="Evezh – Veille logicielle artisanale")
|
||||
subparsers = parser.add_subparsers(dest="command")
|
||||
|
||||
init_parser = subparsers.add_parser("init", help="Initialiser la base de données")
|
||||
|
||||
check_parser = subparsers.add_parser("check")
|
||||
check_parser.add_argument("--config")
|
||||
check_parser.add_argument("--output")
|
||||
check_parser.add_argument("--stdout", action="store_true")
|
||||
|
||||
sync_parser = subparsers.add_parser("sync")
|
||||
sync_parser.add_argument("--config", required=True)
|
||||
sync_parser.add_argument("--db", required=True)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.command == "init":
|
||||
init_db()
|
||||
|
||||
if args.command == "check":
|
||||
state = check.load_state(args.output) if args.output else {}
|
||||
results = check.check_versions(args.config, state)
|
||||
new_state = {}
|
||||
updated = []
|
||||
|
||||
for r in results:
|
||||
name, version, url = r["name"], r["version"], r["url"]
|
||||
if state.get(name, {}).get("version") != version:
|
||||
updated.append(r)
|
||||
new_state[name] = {"version": version, "url": url}
|
||||
|
||||
if args.output:
|
||||
check.save_state(args.output, new_state)
|
||||
|
||||
if updated:
|
||||
print(f"\n{len(updated)} mise(s) à jour détectée(s) :")
|
||||
for r in updated:
|
||||
print(f" - {r['name']} → {r['version']}")
|
||||
else:
|
||||
print("Aucun changement détecté.")
|
||||
|
||||
if args.stdout:
|
||||
print("\n--- Résultat complet ---")
|
||||
print(json.dumps(results, indent=2))
|
||||
|
||||
elif args.command == "sync":
|
||||
check.sync_db(args.config)
|
||||
Loading…
Add table
Add a link
Reference in a new issue