objectiveai_sdk/cli/command/config/functions/profiles/favorites/add/
mod.rs1use crate::RemotePathCommitOptional;
4use crate::cli::command::CommandRequest;
5
6#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
7#[schemars(rename = "cli.command.config.functions.profiles.favorites.add.Request")]
8pub struct Request {
9 pub path_type: Path,
10 pub name: String,
11 pub path: RemotePathCommitOptional,
12 pub note: String,
13}
14
15#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
16#[schemars(rename = "cli.command.config.functions.profiles.favorites.add.Path")]
17pub enum Path {
18 #[serde(rename = "config/functions/profiles/favorites/add")]
19 ConfigFunctionsProfilesFavoritesAdd,
20}
21
22impl CommandRequest for Request {
23 fn into_command(&self) -> Vec<String> {
24 vec![
25 "config".to_string(),
26 "functions".to_string(),
27 "profiles".to_string(),
28 "favorites".to_string(),
29 "add".to_string(),
30 "--name".to_string(),
31 self.name.clone(),
32 "--path".to_string(),
33 crate::cli::command::remote_path_to_arg_string(&self.path),
34 "--note".to_string(),
35 self.note.clone(),
36 ]
37 }
38}
39
40pub type Response = crate::cli::command::Ok;
41
42#[derive(clap::Args)]
43pub struct Args {
44 #[arg(long)]
46 pub name: String,
47 #[arg(long)]
49 pub path: String,
50 #[arg(long)]
52 pub note: String,
53}
54
55#[derive(clap::Args)]
56#[command(args_conflicts_with_subcommands = true)]
57pub struct Command {
58 #[command(flatten)]
59 pub args: Args,
60 #[command(subcommand)]
61 pub schema: Option<Schema>,
62}
63
64#[derive(clap::Subcommand)]
65pub enum Schema {
66 RequestSchema(request_schema::Args),
68 ResponseSchema(response_schema::Args),
70}
71
72impl TryFrom<Args> for Request {
73 type Error = crate::cli::command::FromArgsError;
74 fn try_from(args: Args) -> Result<Self, Self::Error> {
75 let path = args
76 .path
77 .parse::<RemotePathCommitOptional>()
78 .map_err(|msg| crate::cli::command::FromArgsError::path_parse("path", msg))?;
79 Ok(Self {
80 path_type: Path::ConfigFunctionsProfilesFavoritesAdd,
81 name: args.name,
82 path,
83 note: args.note,
84 })
85 }
86}
87
88#[cfg(feature = "cli-executor")]
89pub async fn execute<E: crate::cli::command::CommandExecutor>(
90 executor: &E,
91 request: Request,
92
93 agent_arguments: Option<&crate::cli::command::AgentArguments>,
94 ) -> Result<Response, E::Error> {
95 executor.execute_one(request, agent_arguments).await
96}
97
98pub mod request_schema;
99
100
101pub mod response_schema;
102
103#[cfg(feature = "cli-executor")]
104pub async fn execute_jq<E: crate::cli::command::CommandExecutor>(
105 executor: &E,
106 request: Request,
107 _jq: String,
108
109 agent_arguments: Option<&crate::cli::command::AgentArguments>,
110 ) -> Result<serde_json::Value, E::Error> {
111 let resp: Response = executor.execute_one(request, agent_arguments).await?;
112 Ok(serde_json::to_value(resp).expect("Response serializes"))
113}