Skip to main content

wekan_cli/commands/skill/
show.rs

1use clap::Args;
2
3use crate::{
4    command_result::{CommandSuccess, SkillShowSuccess},
5    error::AppError,
6};
7
8use super::topics::TOPICS;
9
10#[derive(Debug, Args)]
11#[command(
12    after_help = "Examples:\n  wekan skill show\n  wekan skill show cards\n  wekan --output json skill show agent-contract"
13)]
14pub struct ShowArgs {
15    /// Topic name from `wekan skill list`.
16    #[arg(default_value = "core", value_name = "TOPIC")]
17    pub topic: String,
18}
19
20pub(super) fn execute(args: ShowArgs) -> Result<CommandSuccess, AppError> {
21    let topic = TOPICS
22        .iter()
23        .find(|topic| topic.name == args.topic)
24        .ok_or_else(|| {
25            AppError::invalid_input(
26                "unknown skill topic; run `wekan skill list` for available topics",
27            )
28        })?;
29    Ok(CommandSuccess::SkillShown(SkillShowSuccess {
30        cli_version: env!("CARGO_PKG_VERSION").to_owned(),
31        topic: topic.name.to_owned(),
32        content: topic.content.to_owned(),
33    }))
34}