| 1234567891011121314151617181920212223242526272829303132333435363738 |
- import os
- from pathlib import Path
- import typer
- from clients import run
- app = typer.Typer(help="PC-Visit Filetracker")
- def default_session_history() -> Path:
- user_profile = Path(os.environ.get("USERPROFILE", str(Path.home())))
- return user_profile / "AppData" / "Roaming" / "pcvisit Data" / "Session History"
- @app.callback(invoke_without_command=True)
- def app_callback(context: typer.Context) -> None:
- """Verwalten der PC-Visit-Filetracker-Befehle."""
- if context.invoked_subcommand is None:
- typer.echo(context.get_help())
- @app.command()
- def clients(
- directory: Path | None = typer.Argument(None, help="Verzeichnis mit XML-Dateien"),
- output: Path = typer.Option(Path("clients.csv"), "--output", "-o", help="Zielpfad der CSV-Datei"),
- ) -> None:
- """Importiert Client-Daten aus Session-XML-Dateien."""
- directory = directory or default_session_history()
- try:
- xml_count, row_count = run(directory, output)
- except ValueError as error:
- raise typer.BadParameter(str(error), param_hint="directory") from error
- typer.echo(f"{xml_count} XML-Dateien gelesen, {row_count} Einträge nach {output} geschrieben.")
- if __name__ == "__main__":
- app()
|