TSNDep/Src/Comands/Consultas.py
Nique_372 54bd302736
2026-04-25 06:51:23 -05:00

55 lines
2.3 KiB
Python

#+------------------------------------------------------------------+
#| Imports |
#+------------------------------------------------------------------+
# Importamos todo
from Src.Comands.Defines import *
import os
#+------------------------------------------------------------------+
#| |
#+------------------------------------------------------------------+
@tsndep.command()
@click.option('--depth', required=False, type=int, default=10, help='Maximum depth')
def list(depth):
"""Create dependency tree up to specified depth"""
root_path : str = os.getcwd()
repo_name : str = os.path.basename(root_path)
current_depth : int = 0
click.echo(f"[LIST:{repo_name}] {repo_name}/")
GitCommands.imprimir_dependencias_repo(root_path, "", current_depth, max_depth=depth)
#+------------------------------------------------------------------+
#| |
#+------------------------------------------------------------------+
@tsndep.command()
def check():
"""Check dependencies and the repository itself"""
GitCommands.check_repo(os.getcwd())
#+------------------------------------------------------------------+
#| |
#+------------------------------------------------------------------+
@tsndep.command()
@click.option('--output', required=False, type=str, default='dependencies-exported.json', help='Output filename relative to execution')
def export(output):
"""Export all dependencies"""
repo_path : str = os.getcwd()
repo_name : str = os.path.basename(repo_path)
click.echo(f"[EXPORT:{repo_name}] Exporting dependencies...")
exported_data : dict = JsonV.export_dependencies(os.path.dirname(repo_path), repo_path)
# Guardar archivo
output_path : str = os.path.join(repo_path, output)
if JsonV.save_json(output_path, exported_data):
click.echo(f"[EXPORT:{repo_name}] Exported to: {output}")
click.echo(f"[EXPORT:{repo_name}] Total dependencies: {exported_data['total_deps']}")
else:
click.echo(f"[EXPORT:{repo_name}] Error saving file", err=True)