f817847dff
test / run tests/run_tests.py (push) Successful in 20s
One file per subcommand under claude_bottle/cli/, with shared constants and the tty helper in _common.py and dispatch in __init__.py. The public import (from claude_bottle.cli import main) is unchanged, so the root cli.py entrypoint and the test suite see no surface change. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
43 lines
1.2 KiB
Python
43 lines
1.2 KiB
Python
"""cleanup: stop and remove all active claude-bottle containers."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import subprocess
|
|
import sys
|
|
|
|
from .. import docker as docker_mod
|
|
from ..log import info
|
|
from ._common import read_tty_line
|
|
|
|
|
|
def cmd_cleanup(_argv: list[str]) -> int:
|
|
docker_mod.require_docker()
|
|
result = subprocess.run(
|
|
["docker", "ps", "--filter", "name=^claude-bottle-", "--format", "{{.Names}}"],
|
|
capture_output=True,
|
|
text=True,
|
|
)
|
|
containers = (result.stdout or "").strip()
|
|
if not containers:
|
|
info("no active claude-bottle containers")
|
|
return 0
|
|
print(file=sys.stderr)
|
|
for name in containers.splitlines():
|
|
info(f"found: {name}")
|
|
print(file=sys.stderr)
|
|
sys.stderr.write("claude-bottle: remove all of the above? [y/N] ")
|
|
sys.stderr.flush()
|
|
reply = read_tty_line()
|
|
if reply not in ("y", "Y", "yes", "YES"):
|
|
info("aborted")
|
|
return 0
|
|
for name in containers.splitlines():
|
|
info(f"removing {name}")
|
|
subprocess.run(
|
|
["docker", "rm", "-f", name],
|
|
stdout=subprocess.DEVNULL,
|
|
stderr=subprocess.DEVNULL,
|
|
)
|
|
info("done")
|
|
return 0
|