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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
use clap::{Parser, Subcommand};
#[derive(Parser)]
#[command(name = "fakekey")]
#[command(about = "API Key Proxy Agent")]
#[command(version)]
pub struct Cli {
#[command(subcommand)]
pub command: Commands,
}
#[derive(Subcommand)]
pub enum Commands {
/// Initialize configuration and generate CA certificate
Init,
/// Start the proxy server
Start {
/// Port to listen on
#[arg(short, long, default_value_t = 1155)]
port: u16,
/// Run in foreground (default is background)
#[arg(short, long)]
foreground: bool,
},
/// Add an API key
Add {
/// Unique name for this key (e.g., my-openai-key)
#[arg(short, long)]
name: String,
/// Real API key
#[arg(short, long)]
key: String,
/// Use template (e.g., openai, anthropic, github)
#[arg(short, long)]
template: Option<String>,
/// Custom endpoints (comma-separated, e.g., api.openai.com,custom.example.com)
#[arg(long)]
endpoints: Option<String>,
},
/// List all configured API keys
List,
/// Show details for a specific key
Show {
/// Key name
#[arg(short, long)]
name: String,
},
/// Remove an API key configuration
Remove {
/// Key name
#[arg(short, long)]
name: String,
},
/// Check proxy status
Status,
/// View logs
Logs {
/// Follow log output
#[arg(short, long)]
follow: bool,
},
/// Certificate management
Cert {
#[command(subcommand)]
action: CertAction,
},
/// Stop the proxy server
Stop,
/// List available service templates
Templates,
/// Interactive setup wizard
Onboard,
/// Run a CLI tool with proxy automatically configured
Run {
/// Tool name (e.g., claude, openclaw)
tool: String,
/// Additional arguments to pass to the tool
#[arg(trailing_var_arg = true, allow_hyphen_values = true)]
args: Vec<String>,
},
}
#[derive(Subcommand)]
pub enum CertAction {
/// Export CA certificate
Export {
/// Output path
#[arg(short, long)]
output: Option<String>,
},
}