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(long, env = "ANTHROPIC_API_KEY", help = "Anthropic (Claude) API key")]
65    pub anthropic_key: Option<String>,
66
67    #[arg(long, env = "OPENAI_API_KEY", help = "OpenAI (GPT) API key")]
68    pub openai_key: Option<String>,
69
70    #[arg(long, env = "GEMINI_API_KEY", help = "Google AI (Gemini) API key")]
71    pub gemini_key: Option<String>,
72
73    #[arg(long, env = "GITHUB_TOKEN", help = "GitHub token (optional)")]
74    pub github_token: Option<String>,
75}
76
77impl CreateArgs {
78    pub const fn has_api_key(&self) -> bool {
79        self.anthropic_key.is_some() || self.openai_key.is_some() || self.gemini_key.is_some()
80    }
81
82    #[must_use]
83    pub fn normalized(mut self) -> Self {
84        self.anthropic_key = none_if_blank(self.anthropic_key);
85        self.openai_key = none_if_blank(self.openai_key);
86        self.gemini_key = none_if_blank(self.gemini_key);
87        self.github_token = none_if_blank(self.github_token);
88        self
89    }
90}
91
92#[derive(Clone, Copy, Debug, ValueEnum)]
93pub enum TenantTypeArg {
94    Local,
95    Cloud,
96}
97
98#[derive(Debug, Args)]
99pub struct EditArgs {
100    pub name: Option<String>,
101
102    #[arg(long, help = "Set Anthropic API key")]
103    pub set_anthropic_key: Option<String>,
104
105    #[arg(long, help = "Set OpenAI API key")]
106    pub set_openai_key: Option<String>,
107
108    #[arg(long, help = "Set Gemini API key")]
109    pub set_gemini_key: Option<String>,
110
111    #[arg(long, help = "Set GitHub token")]
112    pub set_github_token: Option<String>,
113
114    #[arg(long, help = "Set database URL")]
115    pub set_database_url: Option<String>,
116
117    #[arg(long, help = "Set external URL (cloud profiles)")]
118    pub set_external_url: Option<String>,
119
120    #[arg(long, help = "Set server host")]
121    pub set_host: Option<String>,
122
123    #[arg(long, help = "Set server port")]
124    pub set_port: Option<u16>,
125}
126
127impl EditArgs {
128    pub const fn has_updates(&self) -> bool {
129        self.set_anthropic_key.is_some()
130            || self.set_openai_key.is_some()
131            || self.set_gemini_key.is_some()
132            || self.set_github_token.is_some()
133            || self.set_database_url.is_some()
134            || self.set_external_url.is_some()
135            || self.set_host.is_some()
136            || self.set_port.is_some()
137    }
138}
139
140#[derive(Clone, Copy, Debug, ValueEnum)]
141pub enum ShowFilter {
142    All,
143    Agents,
144    Mcp,
145    Skills,
146    Ai,
147    Web,
148    Content,
149    Env,
150    Settings,
151}