Skip to main content

systemprompt_cli/commands/cloud/profile/
args.rs

1//! Clap argument and command types for `cloud profile`.
2//!
3//! Copyright (c) systemprompt.io — Business Source License 1.1.
4//! See <https://systemprompt.io> for licensing details.
5
6use clap::{Args, Subcommand, ValueEnum};
7use systemprompt_models::none_if_blank;
8
9#[derive(Debug, Subcommand)]
10pub enum ProfileCommands {
11    #[command(about = "Create a new profile", hide = true)]
12    Create(CreateArgs),
13
14    #[command(about = "List all profiles")]
15    List,
16
17    #[command(
18        about = "Show profile configuration",
19        after_help = "EXAMPLES:\n  systemprompt cloud profile show\n  systemprompt cloud profile \
20                      show --filter agents\n  systemprompt cloud profile show --json"
21    )]
22    Show {
23        name: Option<String>,
24
25        #[arg(short, long, value_enum, default_value = "all")]
26        filter: ShowFilter,
27
28        #[arg(long, help = "Output as JSON")]
29        json: bool,
30
31        #[arg(long, help = "Output as YAML")]
32        yaml: bool,
33    },
34
35    #[command(about = "Delete a profile")]
36    Delete(DeleteArgs),
37
38    #[command(about = "Edit profile configuration")]
39    Edit(EditArgs),
40}
41
42#[derive(Debug, Args)]
43pub struct DeleteArgs {
44    pub name: String,
45
46    #[arg(short = 'y', long, help = "Skip confirmation prompts")]
47    pub yes: bool,
48}
49
50#[derive(Debug, Args)]
51pub struct CreateArgs {
52    pub name: String,
53
54    #[arg(
55        long = "tenant-id",
56        env = "SYSTEMPROMPT_TENANT_ID",
57        help = "Tenant ID (required in non-interactive mode)"
58    )]
59    pub tenant: Option<String>,
60
61    #[arg(long, value_enum, default_value = "local", help = "Tenant type")]
62    pub tenant_type: TenantTypeArg,
63
64    #[arg(
65        long,
66        env = "ANTHROPIC_API_KEY",
67        hide_env_values = true,
68        help = "Anthropic (Claude) API key"
69    )]
70    pub anthropic_key: Option<String>,
71
72    #[arg(
73        long,
74        env = "OPENAI_API_KEY",
75        hide_env_values = true,
76        help = "OpenAI (GPT) API key"
77    )]
78    pub openai_key: Option<String>,
79
80    #[arg(
81        long,
82        env = "GEMINI_API_KEY",
83        hide_env_values = true,
84        help = "Google AI (Gemini) API key"
85    )]
86    pub gemini_key: Option<String>,
87
88    #[arg(
89        long,
90        env = "GITHUB_TOKEN",
91        hide_env_values = true,
92        help = "GitHub token (optional)"
93    )]
94    pub github_token: Option<String>,
95}
96
97impl CreateArgs {
98    pub const fn has_api_key(&self) -> bool {
99        self.anthropic_key.is_some() || self.openai_key.is_some() || self.gemini_key.is_some()
100    }
101
102    #[must_use]
103    pub fn normalized(mut self) -> Self {
104        self.anthropic_key = none_if_blank(self.anthropic_key);
105        self.openai_key = none_if_blank(self.openai_key);
106        self.gemini_key = none_if_blank(self.gemini_key);
107        self.github_token = none_if_blank(self.github_token);
108        self
109    }
110}
111
112#[derive(Clone, Copy, Debug, ValueEnum)]
113pub enum TenantTypeArg {
114    Local,
115    Cloud,
116}
117
118#[derive(Debug, Args)]
119pub struct EditArgs {
120    pub name: Option<String>,
121
122    #[arg(long, help = "Set Anthropic API key")]
123    pub set_anthropic_key: Option<String>,
124
125    #[arg(long, help = "Set OpenAI API key")]
126    pub set_openai_key: Option<String>,
127
128    #[arg(long, help = "Set Gemini API key")]
129    pub set_gemini_key: Option<String>,
130
131    #[arg(long, help = "Set GitHub token")]
132    pub set_github_token: Option<String>,
133
134    #[arg(long, help = "Set database URL")]
135    pub set_database_url: Option<String>,
136
137    #[arg(long, help = "Set external URL (cloud profiles)")]
138    pub set_external_url: Option<String>,
139
140    #[arg(long, help = "Set server host")]
141    pub set_host: Option<String>,
142
143    #[arg(long, help = "Set server port")]
144    pub set_port: Option<u16>,
145}
146
147impl EditArgs {
148    pub const fn has_updates(&self) -> bool {
149        self.set_anthropic_key.is_some()
150            || self.set_openai_key.is_some()
151            || self.set_gemini_key.is_some()
152            || self.set_github_token.is_some()
153            || self.set_database_url.is_some()
154            || self.set_external_url.is_some()
155            || self.set_host.is_some()
156            || self.set_port.is_some()
157    }
158}
159
160#[derive(Clone, Copy, Debug, ValueEnum)]
161pub enum ShowFilter {
162    All,
163    Agents,
164    Mcp,
165    Skills,
166    Ai,
167    Web,
168    Content,
169    Env,
170    Settings,
171}