Skip to main content

systemprompt_cli/commands/core/content/link/
mod.rs

1pub mod delete;
2pub mod generate;
3pub mod list;
4pub mod performance;
5pub mod show;
6
7use crate::cli_settings::CliConfig;
8use crate::shared::render_result;
9use anyhow::{Context, Result};
10use clap::Subcommand;
11
12#[derive(Debug, Subcommand)]
13pub enum LinkCommands {
14    #[command(about = "Generate a trackable campaign link")]
15    Generate(generate::GenerateArgs),
16
17    #[command(about = "Show link details by short code")]
18    Show(show::ShowArgs),
19
20    #[command(about = "List links by campaign or content")]
21    List(list::ListArgs),
22
23    #[command(about = "Show link performance metrics")]
24    Performance(performance::PerformanceArgs),
25
26    #[command(about = "Delete a link")]
27    Delete(delete::DeleteArgs),
28}
29
30pub async fn execute(command: LinkCommands, config: &CliConfig) -> Result<()> {
31    match command {
32        LinkCommands::Generate(args) => {
33            let result = generate::execute(args, config)
34                .await
35                .context("Failed to generate link")?;
36            render_result(&result);
37        },
38        LinkCommands::Show(args) => {
39            let result = show::execute(args, config)
40                .await
41                .context("Failed to show link")?;
42            render_result(&result);
43        },
44        LinkCommands::List(args) => {
45            let result = list::execute(args, config)
46                .await
47                .context("Failed to list links")?;
48            render_result(&result);
49        },
50        LinkCommands::Performance(args) => {
51            let result = performance::execute(args, config)
52                .await
53                .context("Failed to get link performance")?;
54            render_result(&result);
55        },
56        LinkCommands::Delete(args) => {
57            let result = delete::execute(args, config)
58                .await
59                .context("Failed to delete link")?;
60            render_result(&result);
61        },
62    }
63    Ok(())
64}