Manage Cactus Cloud API key.
(args)
| 1326 | |
| 1327 | |
| 1328 | def cmd_auth(args): |
| 1329 | """Manage Cactus Cloud API key.""" |
| 1330 | from .config_utils import CactusConfig |
| 1331 | |
| 1332 | config = CactusConfig() |
| 1333 | |
| 1334 | if args.clear: |
| 1335 | config.clear_api_key() |
| 1336 | print_color(GREEN, "API key cleared.") |
| 1337 | return 0 |
| 1338 | |
| 1339 | api_key = config.get_api_key() |
| 1340 | |
| 1341 | if api_key: |
| 1342 | masked = api_key[:4] + "..." + api_key[-4:] |
| 1343 | print(f"Current API key: {masked}") |
| 1344 | else: |
| 1345 | print("No API key set.") |
| 1346 | |
| 1347 | if args.status: |
| 1348 | return 0 |
| 1349 | |
| 1350 | print() |
| 1351 | print("Get your cloud key at \033[1;36mhttps://www.cactuscompute.com/dashboard/api-keys\033[0m") |
| 1352 | new_key = input("Enter new API key (press Enter to skip): ").strip() |
| 1353 | if new_key: |
| 1354 | config.set_api_key(new_key) |
| 1355 | masked = new_key[:4] + "..." + new_key[-4:] |
| 1356 | print_color(GREEN, f"API key saved: {masked}") |
| 1357 | return 0 |
| 1358 | |
| 1359 | |
| 1360 | def cmd_eval(args): |
no test coverage detected