codex-auth-manager 0.1.1

A deadly simple Codex auth manager.
Documentation
# codex-auth-manager (cam)

[![GitHub License](https://img.shields.io/github/license/PRO-2684/codex-auth-manager?logo=opensourceinitiative)](https://github.com/PRO-2684/codex-auth-manager/blob/main/LICENSE)
[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/PRO-2684/codex-auth-manager/release.yml?logo=githubactions)](https://github.com/PRO-2684/codex-auth-manager/blob/main/.github/workflows/release.yml)
[![GitHub Release](https://img.shields.io/github/v/release/PRO-2684/codex-auth-manager?logo=githubactions)](https://github.com/PRO-2684/codex-auth-manager/releases)
[![GitHub Downloads (all assets, all releases)](https://img.shields.io/github/downloads/PRO-2684/codex-auth-manager/total?logo=github)](https://github.com/PRO-2684/codex-auth-manager/releases)
[![Crates.io Version](https://img.shields.io/crates/v/codex-auth-manager?logo=rust)](https://crates.io/crates/codex-auth-manager)
[![Crates.io Total Downloads](https://img.shields.io/crates/d/codex-auth-manager?logo=rust)](https://crates.io/crates/codex-auth-manager)
[![docs.rs](https://img.shields.io/docsrs/codex-auth-manager?logo=rust)](https://docs.rs/codex-auth-manager)

A deadly simple Codex auth manager.

## 📥 Installation

### Using [`binstall`]https://github.com/cargo-bins/cargo-binstall

```shell
cargo binstall codex-auth-manager
```

### Downloading from Releases

Navigate to the [Releases page](https://github.com/PRO-2684/codex-auth-manager/releases) and download respective binary for your platform. Make sure to give it execute permissions.

### Compiling from Source

```shell
cargo install codex-auth-manager --features=cli
```

## 📖 Usage

`cam` manages named Codex auth identities. Each identity is stored under `$CODEX_HOME/codex-auth-manager/`, and CAM switches which identity Codex sees at `$CODEX_HOME/auth.json`.

- `cam` / `cam status` — show the current auth state
- `cam list` — list saved identities
- `cam capture <identity> [--force]` — save the current native Codex auth file as an identity and make it active
- `cam use <identity> [--force]` — make an existing identity active
- `cam detach [--force]` — stop using the active CAM-managed identity

### Shell Completion

Completions are generated by `cam` and include saved identity names for commands like `cam use`. For Bash:

```shell
mkdir -p ~/.local/share/bash-completion/completions
echo 'source <(COMPLETE=bash cam)' > ~/.local/share/bash-completion/completions/cam
```

Other shells [supported by `clap_complete`](https://docs.rs/clap_complete/latest/clap_complete/aot/enum.Shell.html#variants) can generate their setup script with `COMPLETE=<shell> cam`.

## 💡 Examples

Say that you've logged into Codex with your personal account. Now you've got a new work account, and you want to switch between them without logging in and out every time. With `cam`, you can capture your auth states as identities, which can be switched back to at any time.

```shell
# Capture the current auth state as "personal" identity
cam capture personal
```

Now `auth.json` is moved to `$CODEX_HOME/codex-auth-manager/personal.json`, and a symlink is created at `$CODEX_HOME/auth.json` pointing to it. Then you `detach` the current identity (which basically removes the symlink) and log in to Codex with your work account:

```shell
# Detach the current identity
cam detach
# Log in to Codex with your work account as usual (e.g. via `codex login`)
```

You can capture the auth state again as "work" identity:

```shell
# Capture the current auth state as "work" identity
cam capture work
```

Now you have two identities saved. You can switch between them with `cam use`:

```shell
# Switch to "personal" identity
cam use personal
# Switch back to "work" identity
cam use work
```

To list all saved identities:

```shell
$ cam list
  personal
* work
```

## 🎉 Credits

TODO