intelli_shell/lib.rs
1//! _Like IntelliSense, but for shells!_
2//!
3//! 
4//!
5//! IntelliShell is a command-line tool that acts as a smart bookmark manager.
6//! It helps you find, organize, and reuse complex shell commands without ever leaving your terminal.
7//!
8//! # Features
9//!
10//! - **Seamless Shell Integration**: Search with `ctrl+space`, bookmark with `ctrl+b` or fix with `ctrl+x`
11//! - **Dynamic Variables**: Create command templates with `{{variables}}` and replace them on the fly
12//! - **Smart Completions**: Power up your variables with dynamic suggestions from any command
13//! - **AI-Powered Commands**: Generate, fix, and import commands effortlessly using local or remote LLMs
14//! - **Highly Configurable**: Tailor search modes, keybindings, themes, and even search-ranking algorithms
15//! - **Workspace-Aware**: Automatically discovers and loads commands from your workspace's directory
16//! - **Import / Export**: Share your command library using files, HTTP endpoints, or even Gists
17//! - **TLDR Integration**: Fetch and import command examples from [tldr](https://github.com/tldr-pages/tldr) pages
18//! - **Flexible Interface**: Choose between a non-intrusive (inline) or an immersive (full-screen) TUI
19//!
20//! To get started, check out the [repository](https://github.com/lasantosr/intelli-shell) or read the
21//! [IntelliShell Book](https://lasantosr.github.io/intelli-shell/) for comprehensive guides and examples.
22
23/// Configuration management for the application.
24///
25/// This module handles loading, parsing, and providing access to the application's configuration settings.
26pub mod config;
27
28/// Tracing and logs management for the application.
29///
30/// This module is responsible for setting up and configuring the application's logging system using the `tracing`
31/// crate.
32///
33/// It initializes a subscriber that directs logs to a dedicated log file within the application's data directory.
34pub mod logging;
35
36/// Centralized error and panic handling for the application.
37///
38/// This module sets up enhanced error reporting using `color-eyre` and configures custom panic hooks.
39///
40/// It ensures that errors and panics are gracefully handled, logged to the designated log file, and presented to the
41/// user.
42pub mod errors;
43
44/// Provides a Terminal User Interface (TUI) management system.
45///
46/// This module orchestrates the TUI lifecycle, including terminal setup (raw mode, alternate screen or inline display),
47/// event handling (keyboard, mouse, paste, resize, focus, periodic ticks, and renders), and rendering the user
48/// interface.
49///
50/// It manages the event loop and provides mechanisms to enter and exit the TUI cleanly, restoring the terminal to its
51/// original state.
52pub mod tui;
53
54/// Defines and parses the command-line interface (CLI) for the application.
55///
56/// This module uses the `clap` crate to define the structure of the CLI, including subcommands, arguments, and help
57/// messages. It handles parsing command-line arguments provided by the user into a structured format that the
58/// application can easily process.
59///
60/// It is the primary entry point for interacting with the application via the command line.
61pub mod cli;
62
63/// Contains the main application logic and orchestration.
64///
65/// This module defines the `App` struct, which serves as the central coordinator for the application. It holds the
66/// application's configuration and manages the overall program flow based on the parsed command-line arguments.
67///
68/// It dispatches execution to specific processes (interactive or non-interactive) and, for interactive processes,
69/// manages the Terminal User Interface (TUI) lifecycle, handles events, and processes user actions.
70pub mod app;
71
72/// Defines and implements the distinct operational processes or commands the application can run.
73///
74/// This module provides traits (`Process`, `InteractiveProcess`) to abstract the concept of an executable task within
75/// the application, differentiating between those that run non-interactively and those that require a Terminal User
76/// Interface.
77///
78/// It also defines the standard structure for process output (`ProcessOutput`) and contains the specific
79/// implementations of these processes.
80pub mod process;
81
82/// Provides the building blocks and interface for interactive Terminal User Interface (TUI) elements.
83///
84/// This module defines the `Component` trait, which is the fundamental interface for any UI element that can be
85/// displayed within the TUI.
86///
87/// Components are responsible for rendering themselves, processing user input events (keyboard, mouse, paste), managing
88/// their internal state, and performing periodic updates.
89///
90/// This module also serves as a container for specific concrete component implementations used by interactive
91/// processes.
92pub mod component;
93
94/// Contains custom implementations of [`ratatui`] widgets used by components.
95pub mod widgets;
96
97/// Defines the core data structures and models for the application's business domain.
98///
99/// This module serves as a central collection point and namespace for the fundamental data types that represent the key
100/// entities and concepts within the application, such as commands and their associated variables.
101pub mod model;
102
103/// Encapsulates the core business logic and operations of the application.
104///
105/// This module contains the implementation of the application's key functionalities, acting upon the data models
106/// defined in the `model` module.
107///
108/// It orchestrates interactions with the `storage` layer to persist and retrieve data and provides the necessary
109/// operations consumed by the `process` and potentially other layers.
110pub mod service;
111
112/// Provides the data access layer for the application, abstracting the underlying storage implementation.
113///
114/// This module is responsible for interacting with the persistent data store (currently SQLite).
115///
116/// It defines the `SqliteStorage` struct and methods for database initialization, applying migrations, and performing
117/// data operations related to the application's models.
118pub mod storage;
119
120/// Provides various utility functions and extension traits for common tasks.
121///
122/// This module contains general-purpose helpers that don't fit neatly into other domain-specific modules. This includes
123/// functions for string manipulation, as well as potentially other reusable components or patterns.
124pub mod utils;
125
126/// Encapsulates all interactions with Large Language Models (LLMs).
127///
128/// This module provides the client for the application's AI-powered features, such as generating, fixing, and
129/// explaining shell commands. It defines a common interface for interacting with different AI providers.
130pub mod ai;