Crate ipfrs_cli

Crate ipfrs_cli 

Source
Expand description

IPFRS CLI Library

This library provides the core functionality for the IPFRS command-line interface. While primarily used by the binary, it also exposes utilities for output formatting, configuration management, and interactive shell support.

§Modules

  • commands - Command handler implementations (modular refactoring)
  • config - Configuration file management and settings (with caching)
  • output - Output formatting with colors and tables
  • plugin - Plugin system for extending CLI with custom commands
  • progress - Progress indicators for long-running operations
  • shell - Interactive REPL shell implementation
  • tui - Terminal User Interface dashboard
  • utils - Utility functions for maintenance and updates

§Performance Optimizations

The CLI has been optimized for fast startup and low latency:

  • Config Caching: Configuration files are loaded once and cached globally using std::sync::OnceLock to avoid repeated disk I/O.
  • Lazy Initialization: Heavy modules are only loaded when needed.
  • Minimal Dependencies: Core functionality uses lightweight dependencies.

§Examples

use ipfrs_cli::output::{format_bytes, OutputStyle};

// Format file sizes
let size = format_bytes(1048576);
assert_eq!(size, "1.00 MB");

// Create output style
let style = OutputStyle::new(true, "text");
assert_eq!(style.format, "text");

§Configuration Management

use ipfrs_cli::config::Config;

// Load config with caching (fast on subsequent calls)
let config = Config::load().unwrap();
assert_eq!(config.general.log_level, "info");

// Force fresh load without cache
let fresh_config = Config::load_uncached().unwrap();

Modules§

commands
Command handler modules for IPFRS CLI
config
Configuration management for IPFRS CLI
output
Output formatting and colored output utilities for IPFRS CLI
plugin
Plugin system for IPFRS CLI
progress
Progress bar and spinner utilities for IPFRS CLI
shell
Interactive shell (REPL) for IPFRS
tui
Terminal User Interface (TUI) for IPFRS
utils
Utility functions for CLI maintenance and distribution

Functions§

build_cli
Build the CLI command structure