Update geobot/cli.py
Browse files- geobot/cli.py +61 -4
geobot/cli.py
CHANGED
|
@@ -1,6 +1,63 @@
|
|
| 1 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
"""
|
| 3 |
-
|
| 4 |
-
This just proves the package and entry point are wired up correctly.
|
| 5 |
"""
|
| 6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import argparse
|
| 2 |
+
import sys
|
| 3 |
+
import subprocess
|
| 4 |
+
from pathlib import Path
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
def run_basic_demo() -> None:
|
| 8 |
"""
|
| 9 |
+
Run the basic usage example (examples/01_basic_usage.py).
|
|
|
|
| 10 |
"""
|
| 11 |
+
# Always resolve project root as the top folder containing /geobot/
|
| 12 |
+
project_root = Path(__file__).resolve().parents[1]
|
| 13 |
+
examples_dir = project_root / "examples"
|
| 14 |
+
script = examples_dir / "01_basic_usage.py"
|
| 15 |
+
|
| 16 |
+
script = project_root / "examples" / "01_basic_usage.py"
|
| 17 |
+
print(f"[GeoBot CLI] Running basic demo: {script}")
|
| 18 |
+
sys.exit(
|
| 19 |
+
subprocess.run([sys.executable, str(script)], check=False).returncode
|
| 20 |
+
)
|
| 21 |
+
|
| 22 |
+
def run_taiwan_situation_room() -> None:
|
| 23 |
+
project_root = Path(__file__).resolve().parents[1]
|
| 24 |
+
script = project_root / "examples" / "taiwan_situation_room.py"
|
| 25 |
+
|
| 26 |
+
if not script.exists():
|
| 27 |
+
print(f"[GeoBot CLI] Taiwan demo script not found at: {script}")
|
| 28 |
+
sys.exit(1)
|
| 29 |
+
|
| 30 |
+
print(f"[GeoBot CLI] Launching Taiwan Situation Room: {script}")
|
| 31 |
+
sys.exit(subprocess.run([sys.executable, str(script)], check=False).returncode)
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
def main() -> None:
|
| 35 |
+
import subprocess # local import to avoid issues if not used
|
| 36 |
+
|
| 37 |
+
parser = argparse.ArgumentParser(
|
| 38 |
+
prog="geobot",
|
| 39 |
+
description="GeoBotv1 CLI - Geopolitical forecasting demos",
|
| 40 |
+
)
|
| 41 |
+
subparsers = parser.add_subparsers(dest="command", required=True)
|
| 42 |
+
|
| 43 |
+
# geobot forecast --scenario taiwan
|
| 44 |
+
p_forecast = subparsers.add_parser(
|
| 45 |
+
"forecast", help="Run a forecasting demo scenario"
|
| 46 |
+
)
|
| 47 |
+
p_forecast.add_argument(
|
| 48 |
+
"--scenario",
|
| 49 |
+
type=str,
|
| 50 |
+
default="basic",
|
| 51 |
+
help="Scenario name (e.g. 'basic', 'taiwan')",
|
| 52 |
+
)
|
| 53 |
+
|
| 54 |
+
args = parser.parse_args()
|
| 55 |
+
|
| 56 |
+
if args.command == "forecast":
|
| 57 |
+
scenario = (args.scenario or "").lower()
|
| 58 |
+
if scenario == "taiwan":
|
| 59 |
+
run_taiwan_situation_room()
|
| 60 |
+
else:
|
| 61 |
+
run_basic_demo()
|
| 62 |
+
else:
|
| 63 |
+
parser.print_help()
|