rosetree-0.1.0 is not a library.
RST (RoseTree)
A fast and efficient command-line tool for scanning directories, analyzing file structures, and extracting file contents with support for .gitignore rules.
Features
- ๐ Fast Performance: Multi-threaded file scanning using Rayon
- ๐ Smart File Detection: Accurate UTF-8 text file detection using content inspection
- ๐ฏ Selective Extraction: Choose specific file types to include in the output
- ๐ GitIgnore Support: Optionally apply
.gitignorerules during scanning - ๐ Detailed Statistics: Performance timing breakdown for all operations
- ๐ณ Tree Structure: Generate beautiful directory tree visualization
- ๐ Content Export: Extract file contents to timestamped output files
Installation
From Source (Development)
Usage
Simply run the command in any directory:
The tool will:
- Scan the current directory and all subdirectories
- Detect
.gitignorefiles and ask if you want to apply the rules - Analyze all UTF-8 readable files and group them by extension
- Display available file types for selection
- Extract selected file contents to a timestamped output file
Interactive Prompts
- GitIgnore Rules: Choose
yto respect.gitignorefiles,nto scan all files - File Type Selection:
- Enter specific numbers (e.g.,
1 3 5) to select certain file types - Enter
ato select all file types
- Enter specific numbers (e.g.,
Example Session
Scanning current directory and subdirectories...
Found the following .gitignore files:
- .gitignore
- frontend/.gitignore
Apply .gitignore rules? (y/n):
y
Found the following UTF-8 file types:
1. rs
2. md
3. toml
4. json
5. js
Enter file type numbers to extract (space-separated, 'a' for all types):
1 2 3
Reading file contents...
File contents successfully extracted to: rosetree_20240623_143022.txt
Output Format
The generated file contains:
- File Structure: A tree view of all scanned files
- File Contents: Each file's content with clear separation and headers
Example output structure:
File Structure:
.
โโโ Cargo.toml
โโโ README.md
โโโ src/
โ โโโ main.rs
โโโ target/
================================================================================
File Contents:
================================================================================
Cargo.toml:
--------------------------------------------------------------------------------
[package]
name = "rst"
version = "0.1.0"
...
================================================================================
README.md:
--------------------------------------------------------------------------------
# RST (RoseTree)
...
Performance
RST is optimized for speed:
- Parallel Processing: Files are scanned and processed in parallel
- Smart Sampling: Only reads the first 1024 bytes for UTF-8 detection
- Memory Efficient: Streams file content instead of loading everything into memory
- Timing Reports: Built-in performance monitoring
Example timing output:
Program Operation Execution Times (ยตs):
-------------------------------------------
Find .gitignore files: 234
Collect files: 1,567
Read selected contents: 12,890
Generate tree structure: 456
Generate output string: 2,341
Write to file: 123
-------------------------------------------
Total processing time: 17,611 ยตs
17 ms (approx total)
Dependencies
- rayon - Data parallelism
- chrono - Date and time handling
- ignore - GitIgnore rule processing
- dashmap - Concurrent HashMap
- content_inspector - Binary/text file detection
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
Changelog
v0.1.0
- Initial release
- Basic directory scanning and file extraction
- GitIgnore support
- Multi-threaded processing
- UTF-8 file detection optimization