Display account status including user info and rendering credits.
(api_key: str, api_url: str, client_version: str)
| 111 | |
| 112 | |
| 113 | def print_status(api_key: str, api_url: str, client_version: str) -> None: |
| 114 | """Display account status including user info and rendering credits.""" |
| 115 | codeplainAPI = codeplain_api.CodeplainAPI(api_key, console) |
| 116 | codeplainAPI.api_url = api_url |
| 117 | |
| 118 | # First check client version |
| 119 | version_check = codeplainAPI.connection_check(client_version) |
| 120 | client_version_valid = version_check.get("client_version_valid", False) |
| 121 | min_version = version_check.get("min_client_version", "unknown") |
| 122 | |
| 123 | response = codeplainAPI.status() |
| 124 | |
| 125 | user = response["user"] |
| 126 | api_key_label = response["api_key_label"] |
| 127 | org_owner = response.get("organization_owner_email") |
| 128 | plan_credits = response.get("plan_credits") |
| 129 | purchased_credits = response.get("purchased_credits", []) |
| 130 | promo_credits = response.get("promo_credits", []) |
| 131 | |
| 132 | # Display header information |
| 133 | if client_version_valid: |
| 134 | console.print(f"Version: {client_version}") |
| 135 | else: |
| 136 | from plain2code_console import Plain2CodeConsole |
| 137 | |
| 138 | console.print( |
| 139 | f"Version: {client_version} (outdated — minimum required: {min_version})", |
| 140 | style=Plain2CodeConsole.ERROR_STYLE, |
| 141 | ) |
| 142 | console.print("To update, run: uv tool upgrade codeplain\n", style=Plain2CodeConsole.ERROR_STYLE) |
| 143 | console.print(f"Name: {user['first_name']} {user['last_name']}") |
| 144 | console.print(f"User email: {user['email']}") |
| 145 | console.print(f"Organization owner: {org_owner or 'N/A'}") |
| 146 | console.print(f"API key label: {api_key_label}\n") |
| 147 | |
| 148 | # Display rendering credits section |
| 149 | console.print("Rendering credits:") |
| 150 | |
| 151 | # Display plan credits (free trial or subscription) |
| 152 | if plan_credits: |
| 153 | _display_credit_line(plan_credits) |
| 154 | |
| 155 | # Display purchased credits |
| 156 | for bucket in purchased_credits: |
| 157 | _display_bucket_credit_line(bucket, "Purchased") |
| 158 | |
| 159 | # Display promo credits |
| 160 | for bucket in promo_credits: |
| 161 | _display_bucket_credit_line(bucket, "Promo") |
| 162 | |
| 163 | # Display status messages and management link |
| 164 | _display_status_message(plan_credits, purchased_credits, promo_credits) |
| 165 | console.print("\nTo manage your plan navigate to https://platform.codeplain.ai/plans") |