INNER CODE UNIT · Python
_record_default_provider
ghost-in-the-droid/android-agent · gitd/cli.py:758
def _record_default_provider(provider: str) -> None:
"""Best-effort upsert of DEFAULT_PROVIDER in ./.env (records the preference;
auth is the real work, so failures here are non-fatal)."""
env_path = Path.cwd() / ".env"
key = "DEFAULT_PROVIDER"
try:
lines, found = [], False
if env_path.exists():
for line in env_path.read_text().splitlines():
if line.strip().startswith(f"{key}="):
lines.append(f"{key}={provider}")
found = True
else:
lines.append(line)
if not found:
lines.append(f"{key}={provider}")
env_path.write_text("\n".join(lines) + "\n")
except Exception: