Expand description
Shortcuts TUI Library
A comprehensive library for creating terminal user interfaces that display and manage tools and shortcuts from configuration files.
§Features
- Multiple Configuration Formats: Support for both TOML and JSON configuration files
- Rich TUI Interface: Built with ratatui for a modern terminal experience
- Flexible Organization: Tools can be organized by categories and tagged for easy searching
- Command Execution: Execute tool commands directly from the interface
- Search Functionality: Powerful search across tool names, descriptions, and metadata
- Validation: Built-in configuration validation and error reporting
- Extensible: Modular design allows for easy extension and customization
§Quick Start
use shortcuts_tui::{
config::{Config, Tool, loader::ConfigLoader},
ui::TuiApp,
};
// Load configuration from file
let loader = ConfigLoader::new();
let config = loader.load_file("shortcuts.toml")?;
// Create and run the TUI application
let app = TuiApp::new(config)?;
app.run()?;§Configuration Example
§TOML Format
[metadata]
title = "My Development Tools"
description = "A collection of useful development tools"
version = "1.0"
author = "Developer"
[[categories]]
id = "dev"
name = "Development"
description = "Software development tools"
icon = "💻"
color = "blue"
[[tools]]
id = "git_status"
name = "Git Status"
description = "Check git repository status"
command = "git status"
shortcut = "Ctrl+G S"
category = "dev"
tags = ["git", "vcs"]
priority = 10
enabled = true
[tools.metadata]
documentation = "https://git-scm.com/docs/git-status"§JSON Format
{
"metadata": {
"title": "My Development Tools",
"description": "A collection of useful development tools",
"version": "1.0",
"author": "Developer"
},
"categories": [
{
"id": "dev",
"name": "Development",
"description": "Software development tools",
"icon": "💻",
"color": "blue"
}
],
"tools": [
{
"id": "git_status",
"name": "Git Status",
"description": "Check git repository status",
"command": "git status",
"shortcut": "Ctrl+G S",
"category": "dev",
"tags": ["git", "vcs"],
"priority": 10,
"enabled": true,
"metadata": {
"documentation": "https://git-scm.com/docs/git-status"
}
}
]
}§Architecture
The library is organized into several key modules:
config: Configuration loading, parsing, and validationui: Terminal user interface components and application logicerror: Comprehensive error handling and reporting
§Configuration System
The configuration system supports:
- Multiple file formats (TOML, JSON)
- Automatic format detection
- Schema validation
- Default value handling
- Search path resolution
§User Interface
The TUI provides:
- Multiple view modes (tools, categories, search, help)
- Keyboard navigation and shortcuts
- Real-time search and filtering
- Tool execution capabilities
- Responsive layout design
§Error Handling
Comprehensive error handling with:
- Structured error types
- Context preservation
- User-friendly error messages
- Graceful degradation
Re-exports§
pub use config::Config;pub use config::Tool;pub use config::Category;pub use config::ConfigFormat;pub use error::Result;pub use error::ShortcutsError;pub use error::ConfigError;pub use error::UiError;
Modules§
- config
- Configuration module for handling TOML and JSON configuration files.
- error
- Error handling for the shortcuts-tui application.
- ui
- User interface module for the TUI application.
Constants§
- DESCRIPTION
- Library description
- NAME
- Library name
- VERSION
- Library version information
Functions§
- description
- Get library description
- name
- Get library name
- sample_
config - Create a sample configuration for demonstration purposes
- version
- Get library version information