Skip to main content

lean_ctx/core/providers/
mod.rs

1pub mod cache;
2pub mod config;
3pub mod gitlab;
4
5use serde::{Deserialize, Serialize};
6
7#[derive(Debug, Clone, Serialize, Deserialize)]
8pub struct ProviderResult {
9    pub provider: String,
10    pub resource_type: String,
11    pub items: Vec<ProviderItem>,
12    pub total_count: Option<usize>,
13    pub truncated: bool,
14}
15
16#[derive(Debug, Clone, Serialize, Deserialize)]
17pub struct ProviderItem {
18    pub id: String,
19    pub title: String,
20    pub state: Option<String>,
21    pub author: Option<String>,
22    pub created_at: Option<String>,
23    pub updated_at: Option<String>,
24    pub url: Option<String>,
25    pub labels: Vec<String>,
26    pub body: Option<String>,
27}
28
29impl ProviderResult {
30    pub fn format_compact(&self) -> String {
31        let mut out = format!(
32            "{} {} ({}{}):\n",
33            self.provider,
34            self.resource_type,
35            self.items.len(),
36            if self.truncated { "+" } else { "" }
37        );
38        for item in &self.items {
39            let state = item.state.as_deref().unwrap_or("");
40            let labels = if item.labels.is_empty() {
41                String::new()
42            } else {
43                format!(" [{}]", item.labels.join(","))
44            };
45            out.push_str(&format!(
46                "  #{} {} ({}){}\n",
47                item.id, item.title, state, labels
48            ));
49        }
50        out
51    }
52}