1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
use std::path::PathBuf;
use clap::{Parser, Subcommand};
#[derive(Debug, Parser)]
#[command(name = "codex-switch")]
#[command(about = "Local Codex account switcher")]
#[command(version)]
pub struct Cli {
#[command(subcommand)]
pub command: Command,
}
#[derive(Debug, Subcommand)]
pub enum Command {
/// List stored accounts.
List,
/// Log in with ChatGPT/OpenAI OAuth and save the account.
Login {
/// Account display name.
name: String,
/// Use device authorization instead of browser OAuth.
#[arg(long = "device-auth")]
device_auth: bool,
},
/// Import an existing Codex CLI auth.json.
Import {
/// Account display name.
name: String,
/// Path to auth.json. Defaults to the current Codex auth.json.
#[arg(long)]
file: Option<PathBuf>,
},
/// Export a stored account as Codex CLI auth.json.
Export {
/// Account name, full ID, or unique ID prefix.
account: String,
/// Write auth.json to this file instead of stdout.
#[arg(long)]
file: Option<PathBuf>,
/// Overwrite the output file if it already exists.
#[arg(long, requires = "file")]
force: bool,
},
/// Switch Codex to a stored account.
Switch {
/// Account name, full ID, or unique ID prefix.
account: String,
},
/// Switch to a usable account when the active account is out of usage.
AutoSwitch,
/// Run Codex with runtime account auto-switching.
Run {
/// Codex executable to launch.
#[arg(long, default_value = "codex")]
codex_bin: String,
/// Arguments forwarded to `codex`.
#[arg(value_name = "CODEX_ARGS", num_args = 0.., trailing_var_arg = true, allow_hyphen_values = true)]
codex_args: Vec<String>,
},
/// Show usage for one account, the active account, or all accounts.
Usage {
/// Query every stored account.
#[arg(long, conflicts_with = "account")]
all: bool,
/// Account name, full ID, or unique ID prefix. Defaults to active account.
account: Option<String>,
},
/// Delete a stored account.
Delete {
/// Account name, full ID, or unique ID prefix.
account: String,
},
/// Rename a stored account.
Rename {
/// Account name, full ID, or unique ID prefix.
account: String,
/// New account display name.
new_name: String,
},
}