askrobots / dbbasic-cli
Public
Make a complete, running app (a CRM, a shop, a blog) with one command, such as dbbasic crm.
open_service.py · 970 bytes · 32 lines
| 1 | """Open DBBasic services in browser""" |
| 2 | |
| 3 | import webbrowser |
| 4 | import typer |
| 5 | from rich.console import Console |
| 6 | |
| 7 | from .config import SERVICES |
| 8 | |
| 9 | console = Console() |
| 10 | |
| 11 | def open_service(service: str = typer.Argument(None, help="Service to open (omit for dashboard)")): |
| 12 | """Open DBBasic service in browser""" |
| 13 | |
| 14 | # Default to monitor dashboard |
| 15 | if not service: |
| 16 | service = "monitor" |
| 17 | |
| 18 | if service == "docs": |
| 19 | # Special case for API docs |
| 20 | url = f"{SERVICES['crud']['url']}/docs" |
| 21 | console.print(f"Opening API documentation: [blue]{url}[/blue]") |
| 22 | webbrowser.open(url) |
| 23 | return |
| 24 | |
| 25 | if service not in SERVICES: |
| 26 | console.print(f"[red]Unknown service: {service}[/red]") |
| 27 | console.print(f"Available: {', '.join(SERVICES.keys())} or 'docs' for API docs") |
| 28 | raise typer.Exit(1) |
| 29 | |
| 30 | svc = SERVICES[service] |
| 31 | console.print(f"Opening {svc['name']}: [blue]{svc['url']}[/blue]") |
| 32 | webbrowser.open(svc['url']) |