Make a complete, running app (a CRM, a shop, a blog) with one command, such as dbbasic crm.

0 downloads

Download zip
Clone
Clone with git
git clone https://gitstable.com/git/askrobots/dbbasic-cli.git
HTTPS
https://gitstable.com/git/askrobots/dbbasic-cli.git
SSH
ssh://git@gitstable.com:2222/askrobots/dbbasic-cli.git

Cloning needs no sign-in. Pushing over HTTPS asks for your username and an access token. SSH needs your key under SSH keys.

danq9 Version 0.1.2: Working instant apps! a36b93a 1 year, 2 months ago History
cli.py · 2.9 KB · 105 lines
1#!/usr/bin/env python3
2"""
3DBBasic CLI - Main application
4"""
5
6import typer
7from rich.console import Console
8from rich.table import Table
9from pathlib import Path
10
11from .commands import start, status, stop, logs, ports, open_service
12from .commands import crm, shop, blog
13
14console = Console()
15app = typer.Typer(
16 name="dbbasic",
17 help="DBBasic - The crate engine for web apps. Zero to running app in 30 seconds.",
18 no_args_is_help=True,
19 add_completion=False,
20)
21
22# Phase 1: Core service commands
23app.command("start")(start.start)
24app.command("stop")(stop.stop)
25app.command("status")(status.status)
26app.command("logs")(logs.logs)
27app.command("ports")(ports.ports)
28app.command("open")(open_service.open_service)
29
30# Phase 2: Instant app generators
31app.command("crm")(crm.create_crm)
32app.command("shop")(shop.create_shop)
33app.command("blog")(blog.create_blog)
34
35@app.callback()
36def callback():
37 """
38 DBBasic - Replace your entire stack with one command.
39
40 Quick start:
41 dbbasic crm # Instant CRM app
42 dbbasic shop # Instant e-commerce
43 dbbasic blog # Instant blog
44 """
45 pass
46
47@app.command()
48def version():
49 """Show version information"""
50 from . import __version__
51 console.print(f"[bold blue]DBBasic CLI[/bold blue] version {__version__}")
52 console.print("The crate engine for web apps 🚀")
53
54@app.command()
55def doctor():
56 """Diagnose and fix common issues"""
57 console.print("[bold]🏥 Running diagnostics...[/bold]\n")
58
59 checks = []
60
61 # Check if DuckDB is available
62 try:
63 import duckdb
64 checks.append(("DuckDB", "✅", duckdb.__version__))
65 except ImportError:
66 checks.append(("DuckDB", "❌", "Not installed"))
67
68 # Check if FastAPI is available
69 try:
70 import fastapi
71 checks.append(("FastAPI", "✅", fastapi.__version__))
72 except ImportError:
73 checks.append(("FastAPI", "❌", "Not installed"))
74
75 # Check if ports are available
76 import socket
77 for port in [8000, 8003, 8004, 8005, 8007]:
78 sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
79 result = sock.connect_ex(('localhost', port))
80 sock.close()
81 if result == 0:
82 checks.append((f"Port {port}", "⚠️", "In use"))
83 else:
84 checks.append((f"Port {port}", "✅", "Available"))
85
86 # Display results
87 table = Table(title="System Check")
88 table.add_column("Component", style="cyan")
89 table.add_column("Status", style="bold")
90 table.add_column("Info")
91
92 for component, status, info in checks:
93 table.add_row(component, status, info)
94
95 console.print(table)
96
97 # Check for issues
98 issues = [c for c in checks if c[1] != "✅"]
99 if issues:
100 console.print("\n[yellow]⚠️ Found issues that may need attention[/yellow]")
101 else:
102 console.print("\n[green]✅ All systems operational![/green]")
103
104if __name__ == "__main__":
105 app()