TSNDep/Src/Comands/Consultas.py

54 lines
2.3 KiB
Python
Raw Permalink Normal View History

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