rosetree 0.1.0

A fast command-line tool for scanning directories, analyzing file structures, and extracting file contents with gitignore support
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 .gitignore rules 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

cargo install rosetree

From Source (Development)

git clone https://github.com/huahuadeliaoliao/RoseTree.git
cd RoseTree
cargo build --release

Usage

Simply run the command in any directory:

rst

The tool will:

  1. Scan the current directory and all subdirectories
  2. Detect .gitignore files and ask if you want to apply the rules
  3. Analyze all UTF-8 readable files and group them by extension
  4. Display available file types for selection
  5. Extract selected file contents to a timestamped output file

Interactive Prompts

  • GitIgnore Rules: Choose y to respect .gitignore files, n to scan all files
  • File Type Selection:
    • Enter specific numbers (e.g., 1 3 5) to select certain file types
    • Enter a to select all file types

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:

  1. File Structure: A tree view of all scanned files
  2. 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

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