From 55ebbaef1588633bbfb5d12b5fab10248a7f8775 Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Sat, 6 Jun 2026 16:27:20 +0545 Subject: [PATCH] feat(devgen/cli): improve version callback error messages - Enhanced error messages when version cannot be determined, providing clearer guidance. - Added explicit handling for missing pyproject.toml and TOML parsing errors. - Improved user feedback for installation corruption issues. --- devgen/cli/main.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/devgen/cli/main.py b/devgen/cli/main.py index 9c0ce25..0d6c9b2 100644 --- a/devgen/cli/main.py +++ b/devgen/cli/main.py @@ -48,13 +48,21 @@ def _version_callback(value: bool) -> None: typer.echo(f"devgen version: {version}") else: typer.secho( - "Error: Version not found in pyproject.toml", + "Could not determine version: no `project.version` or " + "`tool.poetry.version` found in pyproject.toml.", fg=typer.colors.RED, err=True, ) - except (FileNotFoundError, KeyError, Exception) as e: + except FileNotFoundError: typer.secho( - f"Error: Could not determine version: {e}", + f"pyproject.toml not found at {pyproject_path}. " + "The installation may be corrupt.", + fg=typer.colors.RED, + err=True, + ) + except toml.TomlDecodeError as e: + typer.secho( + f"pyproject.toml is not valid TOML: {e}", fg=typer.colors.RED, err=True, )