PRD 0003: Bottle Backend abstraction #5
@@ -122,6 +122,11 @@ class BottlePlatform(ABC):
|
|||||||
def cleanup(self, plan: BottleCleanupPlan) -> None:
|
def cleanup(self, plan: BottleCleanupPlan) -> None:
|
||||||
"""Remove everything described by the cleanup plan."""
|
"""Remove everything described by the cleanup plan."""
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
def list_active(self) -> None:
|
||||||
|
"""Print every currently-running bottle on this platform to
|
||||||
|
stderr (name + status)."""
|
||||||
|
|
||||||
|
|
||||||
# Import concrete platform classes AFTER the base types are defined, so
|
# Import concrete platform classes AFTER the base types are defined, so
|
||||||
# each platform module can pull BottleSpec / BottlePlan / BottlePlatform
|
# each platform module can pull BottleSpec / BottlePlan / BottlePlatform
|
||||||
|
|||||||
@@ -527,3 +527,28 @@ class DockerBottlePlatform(BottlePlatform):
|
|||||||
stdout=subprocess.DEVNULL,
|
stdout=subprocess.DEVNULL,
|
||||||
stderr=subprocess.DEVNULL,
|
stderr=subprocess.DEVNULL,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# --- List ---
|
||||||
|
|
||||||
|
def list_active(self) -> None:
|
||||||
|
"""Print all running claude-bottle containers (name + status).
|
||||||
|
Prints a single-line banner if there are none."""
|
||||||
|
docker_mod.require_docker()
|
||||||
|
result = subprocess.run(
|
||||||
|
[
|
||||||
|
"docker", "ps",
|
||||||
|
"--filter", "name=^claude-bottle-",
|
||||||
|
"--format", "{{.Names}}\t{{.Status}}",
|
||||||
|
],
|
||||||
|
capture_output=True,
|
||||||
|
text=True,
|
||||||
|
)
|
||||||
|
containers = (result.stdout or "").strip()
|
||||||
|
if not containers:
|
||||||
|
info("no active claude-bottle containers")
|
||||||
|
return
|
||||||
|
print()
|
||||||
|
for line in containers.splitlines():
|
||||||
|
name, _, status = line.partition("\t")
|
||||||
|
info(f"container: {name} status: {status}")
|
||||||
|
print()
|
||||||
|
|||||||
@@ -1,12 +1,10 @@
|
|||||||
"""list: list available agents or active containers."""
|
"""list: list available agents or active bottles."""
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
import subprocess
|
|
||||||
|
|
||||||
from .. import docker as docker_mod
|
from ..bottles import get_bottle_platform
|
||||||
from ..log import info
|
|
||||||
from ..manifest import Manifest
|
from ..manifest import Manifest
|
||||||
from ._common import PROG, USER_CWD
|
from ._common import PROG, USER_CWD
|
||||||
|
|
||||||
@@ -22,23 +20,5 @@ def cmd_list(argv: list[str]) -> int:
|
|||||||
print(name)
|
print(name)
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
docker_mod.require_docker()
|
get_bottle_platform().list_active()
|
||||||
result = subprocess.run(
|
|
||||||
[
|
|
||||||
"docker", "ps",
|
|
||||||
"--filter", "name=^claude-bottle-",
|
|
||||||
"--format", "{{.Names}}\t{{.Status}}",
|
|
||||||
],
|
|
||||||
capture_output=True,
|
|
||||||
text=True,
|
|
||||||
)
|
|
||||||
containers = (result.stdout or "").strip()
|
|
||||||
if not containers:
|
|
||||||
info("no active claude-bottle containers")
|
|
||||||
return 0
|
|
||||||
print()
|
|
||||||
for line in containers.splitlines():
|
|
||||||
name, _, status = line.partition("\t")
|
|
||||||
info(f"container: {name} status: {status}")
|
|
||||||
print()
|
|
||||||
return 0
|
return 0
|
||||||
|
|||||||
Reference in New Issue
Block a user