MCPcopy Create free account
hub / github.com/clawshell/clawshell / generate_clawshell_config

Function generate_clawshell_config

src/onboard/config_render.rs:13–124  ·  view source on GitHub ↗

Generate the ClawShell TOML configuration content with the given key mapping.

(config: &OnboardConfig)

Source from the content-addressed store, hash-verified

11
12/// Generate the ClawShell TOML configuration content with the given key mapping.
13pub fn generate_clawshell_config(config: &OnboardConfig) -> String {
14 let key_section = match &config.auth_method {
15 OnboardAuthMethod::OAuth { provider_id } => {
16 format!(
17 r#"[[keys]]
18virtual_key = {virtual_key}
19provider = {provider}
20auth = "oauth"
21oauth_provider = {oauth_provider}
22"#,
23 virtual_key = toml_string(&config.virtual_api_key),
24 provider = toml_string(&config.provider),
25 oauth_provider = toml_string(provider_id),
26 )
27 }
28 OnboardAuthMethod::StaticKey => {
29 format!(
30 r#"[[keys]]
31virtual_key = {virtual_key}
32real_key = {real_key}
33provider = {provider}
34"#,
35 virtual_key = toml_string(&config.virtual_api_key),
36 real_key = toml_string(&config.real_api_key),
37 provider = toml_string(&config.provider),
38 )
39 }
40 };
41
42 let oauth_providers_section = match &config.auth_method {
43 OnboardAuthMethod::OAuth { provider_id } => {
44 format!(
45 r#"
46[[oauth_providers]]
47provider = {provider_id}
48"#,
49 provider_id = toml_string(provider_id),
50 )
51 }
52 OnboardAuthMethod::StaticKey => String::new(),
53 };
54
55 let mut output = format!(
56 r#"# ClawShell Configuration
57version = "{version}"
58log_level = "info"
59
60[server]
61host = "{host}"
62port = {port}
63
64[upstream]
65openai_base_url = "https://api.openai.com"
66openrouter_base_url = "https://openrouter.ai/api"
67anthropic_base_url = "https://api.anthropic.com"
68minimax_base_url = "https://api.minimax.io"
69
70{key_section}[dlp]

Calls 1

toml_string_arrayFunction · 0.85