Skip to content

Commit

Permalink
chore: keep comments in yaml on api_jwt_token setup
Browse files Browse the repository at this point in the history
  • Loading branch information
dantetemplar committed Nov 19, 2024
1 parent 8a86bc5 commit 38279a5
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/api/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,13 @@ def check_and_prompt_api_jwt_token():
token = input(" Enter the token here (or press Enter to skip): ").strip()

if token:
accounts["api_jwt_token"] = token
settings["accounts"] = accounts
try:
with open(SETTINGS_FILE, "r") as f:
as_text = f.read()
as_text = as_text.replace("api_jwt_token: null", f"api_jwt_token: {token}")
as_text = as_text.replace("api_jwt_token: ...", f"api_jwt_token: {token}")
with open(SETTINGS_FILE, "w") as f:
yaml.safe_dump(settings, f, default_flow_style=False, sort_keys=False)
f.write(as_text)
print(" ✅ `accounts.api_jwt_token` has been updated in `settings.yaml`.")
except Exception as e:
print(f" ❌ Error updating `settings.yaml`: {e}")
Expand Down

0 comments on commit 38279a5

Please sign in to comment.