prompts.rs

 1use crate::{
 2    templates::{BaseTemplate, Template, Templates, WorktreeData},
 3    thread::Prompt,
 4};
 5use anyhow::Result;
 6use gpui::{App, Entity};
 7use project::Project;
 8
 9#[allow(dead_code)]
10struct BasePrompt {
11    project: Entity<Project>,
12}
13
14impl Prompt for BasePrompt {
15    fn render(&self, templates: &Templates, cx: &App) -> Result<String> {
16        BaseTemplate {
17            os: std::env::consts::OS.to_string(),
18            shell: util::get_system_shell(),
19            worktrees: self
20                .project
21                .read(cx)
22                .worktrees(cx)
23                .map(|worktree| WorktreeData {
24                    root_name: worktree.read(cx).root_name().to_string(),
25                })
26                .collect(),
27        }
28        .render(templates)
29    }
30}