mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-06 02:54:26 +00:00
3529 invalid comments in 528 files, grandfathered in while the linter only saw the working-tree diff. Removal ran through the linter's own collectors, so detection and deletion cannot drift: a comment whose opener line is blank before it and whose closer line is blank after it loses all its lines, anything else loses only the comment region, and a line left holding a bare delimiter goes with it. Five files keep their comments behind a nocheck marker instead. Four are upstream configs whose inline docs are upstream's own (mautrix, systemd journald, nextcloud-oidc-login, MediaWiki). In littlejs the commented-out entries ARE the deactivation mechanism for an example tile, so deleting them would delete configuration. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
62 lines
1.8 KiB
Python
62 lines
1.8 KiB
Python
from __future__ import annotations
|
|
|
|
import argparse
|
|
import os
|
|
|
|
from .common import make_compose
|
|
|
|
|
|
def add_parser(sub: argparse._SubParsersAction) -> None:
|
|
p = sub.add_parser("exec", help="Execute a command inside the infinito container.")
|
|
p.add_argument(
|
|
"--env",
|
|
action="append",
|
|
default=[],
|
|
metavar="KEY=VALUE",
|
|
help=(
|
|
"Inject KEY=VALUE into the container environment for this "
|
|
"exec call. Repeatable. Lets bash callers pass per-run "
|
|
"context (INFINITO_INVENTORY_FILE, apps, ...) into in-container "
|
|
"helper scripts without inlining heredocs."
|
|
),
|
|
)
|
|
p.add_argument(
|
|
"cmd",
|
|
nargs=argparse.REMAINDER,
|
|
help="Command to execute (use `--` to separate).",
|
|
)
|
|
p.set_defaults(_handler=handler)
|
|
|
|
|
|
def _parse_env_pairs(pairs: list[str]) -> dict[str, str]:
|
|
parsed: dict[str, str] = {}
|
|
for pair in pairs:
|
|
if "=" not in pair:
|
|
raise SystemExit(f"--env expects KEY=VALUE; got {pair!r} without '='")
|
|
key, value = pair.split("=", 1)
|
|
key = key.strip()
|
|
if not key:
|
|
raise SystemExit(f"--env KEY is empty in {pair!r}")
|
|
parsed[key] = value
|
|
return parsed
|
|
|
|
|
|
def handler(args: argparse.Namespace) -> int:
|
|
compose = make_compose()
|
|
|
|
cmd = list(args.cmd or [])
|
|
if cmd and cmd[0] == "--":
|
|
cmd = cmd[1:]
|
|
if not cmd:
|
|
raise SystemExit("exec requires a command (e.g. exec -- sh -lc 'whoami')")
|
|
|
|
extra_env: dict[str, str] = {}
|
|
services_disabled = os.environ.get("disable", "")
|
|
if services_disabled:
|
|
extra_env["disable"] = services_disabled
|
|
|
|
extra_env.update(_parse_env_pairs(args.env or []))
|
|
|
|
r = compose.exec(cmd, check=False, extra_env=extra_env or None)
|
|
return int(r.returncode)
|