intelli_shell/service/
mod.rs

1use std::path::{Path, PathBuf};
2
3use crate::{config::SearchTuning, storage::SqliteStorage};
4
5mod command;
6mod import_export;
7mod tldr;
8mod variable;
9mod version;
10
11/// Service for managing user commands in IntelliShell
12#[derive(Clone)]
13pub struct IntelliShellService {
14    check_updates: bool,
15    storage: SqliteStorage,
16    tuning: SearchTuning,
17    tldr_repo_path: PathBuf,
18}
19
20impl IntelliShellService {
21    /// Creates a new instance of `IntelliShellService` with the provided storage
22    pub fn new(storage: SqliteStorage, tuning: SearchTuning, data_dir: impl AsRef<Path>, check_updates: bool) -> Self {
23        Self {
24            check_updates,
25            storage,
26            tuning,
27            tldr_repo_path: data_dir.as_ref().join("tldr"),
28        }
29    }
30
31    #[cfg(debug_assertions)]
32    pub async fn query(&self, sql: String) -> color_eyre::eyre::Result<String> {
33        self.storage.query(sql).await
34    }
35}