Repository navigation
Expand file tree
/
Copy pathmain.py
More file actions
61 lines (48 loc) · 1.42 KB
/
Copy pathmain.py
File metadata and controls
61 lines (48 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
"""Forge CLI Main Entry Point"""
import typer
from typing import Optional
from ui.logo import show_logo
from commands.init import init_command
from core.version import __version__
from core.utils.version_checker import check_for_updates
# Create main application
app = typer.Typer(
name="forge",
help="Forge - A modern FastAPI project scaffolding CLI tool",
rich_markup_mode="rich",
add_completion=False
)
# Register commands
app.command(name="init", help="Initialize a new FastAPI project")(init_command)
def version_callback(value: bool) -> None:
"""Version information callback"""
if value:
typer.echo(f"Forge CLI v{__version__}")
raise typer.Exit()
@app.callback(invoke_without_command=True)
def main_callback(
ctx: typer.Context,
version: Optional[bool] = typer.Option(
None,
"--version",
"-v",
help="Show version information",
callback=version_callback,
is_eager=True
)
):
"""
Forge CLI Tool
A powerful FastAPI project scaffolding generator
"""
if ctx.invoked_subcommand is None:
show_logo()
typer.echo() # Empty line
typer.echo(ctx.get_help()) # Show help information
# Check for updates when showing help (non-interactive)
check_for_updates(silent=False, interactive=False)
def main():
"""Main entry function"""
app()
if __name__ == "__main__":
main()