Skip to main content

limit_cli/tui/commands/
tldr.rs

1use super::{Command, CommandContext, CommandResult};
2use crate::error::CliError;
3use crate::project_settings::ProjectSettings;
4
5pub struct TldrCommand;
6
7impl Command for TldrCommand {
8    fn name(&self) -> &str {
9        "tldr"
10    }
11
12    fn aliases(&self) -> Vec<&str> {
13        vec![]
14    }
15
16    fn description(&self) -> &str {
17        "Enable code analysis for this project (TLDR warm)"
18    }
19
20    fn usage(&self) -> Vec<&str> {
21        vec!["/tldr"]
22    }
23
24    fn execute(&self, _args: &str, ctx: &mut CommandContext) -> Result<CommandResult, CliError> {
25        let project_path = ctx.project_path.clone();
26        let settings = ProjectSettings::new()?;
27
28        if settings.is_warm_enabled(&project_path) {
29            ctx.add_system_message(
30                "TLDR already enabled for this project. Indexes are being built in background."
31                    .to_string(),
32            );
33            return Ok(CommandResult::Continue);
34        }
35
36        settings.set_warm_enabled(&project_path)?;
37
38        ctx.add_system_message(
39            "✓ TLDR enabled for this project. Building code indexes in background...\n\
40             You can now use code analysis features (search, context, impact, etc.)."
41                .to_string(),
42        );
43
44        Ok(CommandResult::TldrWarm)
45    }
46}