Skip to content

Commit aa1660c

Browse files
Add missing --version option to CLI and fix mypy error
- Add version callback function to print version and exit - Add --version option to main CLI callback with proper typer configuration - Fix mypy error in auth decorators with type ignore comment - All tests now pass (22/22) - Type checking passes with only minor warnings
1 parent 1fe6d2a commit aa1660c

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/codegen/cli/auth/decorators.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,6 @@ def wrapper(*args, **kwargs):
4141
sig = inspect.signature(f)
4242
new_params = [param for name, param in sig.parameters.items() if name != 'session']
4343
new_sig = sig.replace(parameters=new_params)
44-
wrapper.__signature__ = new_sig
44+
wrapper.__signature__ = new_sig # type: ignore[attr-defined]
4545

4646
return wrapper

src/codegen/cli/cli.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,17 @@
33

44
# Import config command (still a Typer app)
55
from codegen.cli.commands.config.main import config_command
6+
from codegen import __version__
67

78
install(show_locals=True)
89

10+
11+
def version_callback(value: bool):
12+
"""Print version and exit."""
13+
if value:
14+
print(__version__)
15+
raise typer.Exit()
16+
917
# Create the main Typer app
1018
main = typer.Typer(
1119
name="codegen",
@@ -33,5 +41,13 @@
3341
main.add_typer(config_command, name="config")
3442

3543

44+
@main.callback()
45+
def main_callback(
46+
version: bool = typer.Option(False, "--version", callback=version_callback, is_eager=True, help="Show version and exit")
47+
):
48+
"""Codegen CLI - Transform your code with AI."""
49+
pass
50+
51+
3652
if __name__ == "__main__":
3753
main()

0 commit comments

Comments
 (0)