Skip to main content

chezmoi_files/
lib.rs

1//! # chezmoi-files
2//!
3//! A command-line utility and library for generating colorized tree visualizations of file paths.
4//!
5//! This crate provides functionality for:
6//! - Building hierarchical tree structures from file paths
7//! - Filtering paths using glob patterns
8//! - Colorizing output based on file types
9//! - Configuring exclusion and inclusion rules
10//!
11//! ## Usage as a Binary
12//!
13//! ```bash
14//! # Install from crates.io
15//! cargo install chezmoi-files
16//!
17//! # Use with chezmoi
18//! chezmoi managed | chezmoi-files
19//!
20//! # Use with any file list
21//! find . -type f | chezmoi-files --sort name --stats
22//! ```
23//!
24//! ## Usage as a Library
25//!
26//! ```rust
27//! use chezmoi_files::{TreeNode, ColorScheme, Config};
28//!
29//! // Create a tree structure
30//! let mut root = TreeNode::new();
31//! root.add_path(vec!["src", "main.rs"]);
32//! root.add_path(vec!["src", "lib.rs"]);
33//!
34//! // Load configuration
35//! let config = Config::default();
36//!
37//! // Create color scheme
38//! let color_scheme = ColorScheme::new();
39//! ```
40//!
41//! ## Features
42//!
43//! - **Glob Pattern Filtering**: Advanced pattern matching with wildcards
44//!   (`*`, `?`, `[abc]`, `[a-z]`)
45//! - **Customizable Colors**: Configure colors for folders, files, and specific extensions
46//! - **Multiple Sorting Options**: Sort by name, type, or keep original order
47//! - **Statistics**: Display counts of files, directories, and excluded items
48//! - **Fast**: Optimized Rust implementation with minimal overhead
49//!
50//! ## Configuration
51//!
52//! Configuration is loaded from `~/.config/chezmoi/chezmoi-files.toml`:
53//!
54//! ```toml
55//! [excluded-files]
56//! files = [
57//!     "DS_Store",
58//!     "*.tmp",
59//!     "cache/*",
60//! ]
61//!
62//! [included-files]
63//! files = []
64//!
65//! [colors]
66//! enabled = true
67//! folder = "white"
68//! default-file = "blue"
69//!
70//! [colors.extensions]
71//! ".rs" = "red"
72//! ".py" = "green"
73//! ```
74
75// Re-export main modules
76pub mod color;
77pub mod config;
78pub mod tree;
79
80// Re-export commonly used types
81pub use color::ColorScheme;
82pub use config::{ColorConfig, Config, FileList};
83pub use tree::{TreeDepth, TreeNode, TreeParams, TreePart, TreeTrunk};