feat(cli): add interactive account switcher and management tool#70
Open
quangnv13 wants to merge 2 commits into
Open
feat(cli): add interactive account switcher and management tool#70quangnv13 wants to merge 2 commits into
quangnv13 wants to merge 2 commits into
Conversation
- Implement interactive CLI switcher in codex-switch.rs - Add CLI dependency libraries (clap, dialoguer, console, crossterm) - Add cli script to package.json - Refactor console prints in usage.rs to only log when CODEX_DEBUG is set
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🚀 Add Interactive CLI Tool for Account Switching and Management
📝 Description
This Pull Request introduces an interactive command-line interface (CLI) to manage and switch between OpenAI/ChatGPT accounts. It allows users to quickly monitor account usage limits (5-hour and weekly quotas), rename/delete accounts, and perform OAuth authentication flows directly from the terminal.
To prevent console prints from interfering with the interactive terminal UI rendering, this PR also refactors the account usage logging to only output messages when the
CODEX_DEBUGenvironment variable is defined.✨ Key Features
dialoguerandcrosstermfor clean navigation using arrow keys (orj/k) andEnter.cli-config.json, defaults to60seconds), with support for manual refresh by pressingr.🛠️ Changes Details
1. New Binary:
codex-switchsrc-tauri/src/bin/codex-switch.rsimplementing the full terminal user interface, keyboard event handling, auto-refresh scheduling, and terminal restoration safety.2. Dependency Upgrades (
src-tauri/Cargo.toml)Added libraries to build the interactive CLI:
clap(v4.4 withderive) for parsing CLI args and metadata.dialoguer(v0.11) for input prompts, confirmation boxes, and select menus.console(v0.15) for terminal styling and colors.crossterm(v0.29.0) for low-level terminal manipulation (raw mode, cursor hide/show, event polling).3. Log Cleanup (
src-tauri/src/api/usage.rs)println!messages with alog_debug!macro. It ensures console logs are only printed when debugging is explicitly requested viaCODEX_DEBUG=1, keeping the interactive CLI display clean and flicker-free.4. Convenient Command Script (
package.json)cargo run --manifest-path src-tauri/Cargo.toml --bin codex-switch --5. Documentation (
README.md)Run the Interactive CLIdescribing how to run the CLI, its key features, and configuration.🧪 How to Test
j/k.* [Active]).rto manually refresh account usage information.CODEX_DEBUG=1before running exposes the background debug logs.