Skip to main content

objectiveai_sdk/cli/command/config/agents/favorites/del/
mod.rs

1//! `config agents favorites del` — async handler stub.
2
3use crate::cli::command::CommandRequest;
4
5#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
6#[schemars(rename = "cli.command.config.agents.favorites.del.Request")]
7pub struct Request {
8    pub path_type: Path,
9    pub name: String,
10}
11
12#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
13#[schemars(rename = "cli.command.config.agents.favorites.del.Path")]
14pub enum Path {
15    #[serde(rename = "config/agents/favorites/del")]
16    ConfigAgentsFavoritesDel,
17}
18
19impl CommandRequest for Request {
20    fn into_command(&self) -> Vec<String> {
21        vec![
22            "config".to_string(),
23            "agents".to_string(),
24            "favorites".to_string(),
25            "del".to_string(),
26            self.name.clone(),
27        ]
28    }
29}
30
31pub type Response = crate::cli::command::Ok;
32
33#[derive(clap::Args)]
34pub struct Args {
35    /// Favorite name.
36    pub name: String,
37}
38
39#[derive(clap::Args)]
40#[command(args_conflicts_with_subcommands = true)]
41pub struct Command {
42    #[command(flatten)]
43    pub args: Args,
44    #[command(subcommand)]
45    pub schema: Option<Schema>,
46}
47
48#[derive(clap::Subcommand)]
49pub enum Schema {
50    /// Emit the JSON Schema for this leaf's `Request` type and exit.
51    RequestSchema(request_schema::Args),
52    /// Emit the JSON Schema for this leaf's `Response` type and exit.
53    ResponseSchema(response_schema::Args),
54}
55
56impl TryFrom<Args> for Request {
57    type Error = crate::cli::command::FromArgsError;
58    fn try_from(args: Args) -> Result<Self, Self::Error> {
59        Ok(Self { path_type: Path::ConfigAgentsFavoritesDel, name: args.name })
60    }
61}
62
63#[cfg(feature = "cli-executor")]
64pub async fn execute<E: crate::cli::command::CommandExecutor>(
65    executor: &E,
66    request: Request,
67
68        agent_arguments: Option<&crate::cli::command::AgentArguments>,
69    ) -> Result<Response, E::Error> {
70    executor.execute_one(request, agent_arguments).await
71}
72
73pub mod request_schema;
74
75
76pub mod response_schema;
77
78#[cfg(feature = "cli-executor")]
79pub async fn execute_jq<E: crate::cli::command::CommandExecutor>(
80    executor: &E,
81    request: Request,
82    _jq: String,
83
84        agent_arguments: Option<&crate::cli::command::AgentArguments>,
85    ) -> Result<serde_json::Value, E::Error> {
86    let resp: Response = executor.execute_one(request, agent_arguments).await?;
87    Ok(serde_json::to_value(resp).expect("Response serializes"))
88}