Skip to content

Commit 90e39ae

Browse files
committed
cli for local dev, rename compose, better historical dive
1 parent a069ffe commit 90e39ae

3 files changed

Lines changed: 1363 additions & 962 deletions

File tree

cli.py

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
"""Dev CLI for where-the-plow."""
2+
3+
import subprocess
4+
import sys
5+
6+
COMMANDS = {
7+
"dev": "Run uvicorn in development mode with auto-reload",
8+
"start": "Run uvicorn in production mode",
9+
}
10+
11+
APP = "where_the_plow.main:app"
12+
13+
14+
def dev():
15+
subprocess.run(
16+
[
17+
sys.executable,
18+
"-m",
19+
"uvicorn",
20+
APP,
21+
"--reload",
22+
"--host",
23+
"0.0.0.0",
24+
"--port",
25+
"8000",
26+
],
27+
env={**__import__("os").environ, "DB_PATH": "./data/plow.db"},
28+
)
29+
30+
31+
def start():
32+
subprocess.run(
33+
[
34+
sys.executable,
35+
"-m",
36+
"uvicorn",
37+
APP,
38+
"--host",
39+
"0.0.0.0",
40+
"--port",
41+
"8000",
42+
],
43+
)
44+
45+
46+
def usage():
47+
print("Usage: uv run cli.py <command>\n")
48+
print("Commands:")
49+
for name, desc in COMMANDS.items():
50+
print(f" {name:10s} {desc}")
51+
sys.exit(1)
52+
53+
54+
def main():
55+
if len(sys.argv) < 2 or sys.argv[1] not in COMMANDS:
56+
usage()
57+
58+
cmd = sys.argv[1]
59+
{"dev": dev, "start": start}[cmd]()
60+
61+
62+
if __name__ == "__main__":
63+
main()

compose.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
services:
2-
app:
2+
plow:
33
build: .
44
ports:
55
- "127.0.0.1:8000:8000"
@@ -8,4 +8,3 @@ services:
88
environment:
99
- DB_PATH=/data/plow.db
1010
- POLL_INTERVAL=6
11-
restart: unless-stopped

0 commit comments

Comments
 (0)