treestat 1.1.0

A CLI that displays source file counts in a tree view by directory and language
Documentation
# treestat

[![Crates.io](https://img.shields.io/crates/v/treestat?label=crates.io)](https://crates.io/crates/treestat)
[![PyPI](https://img.shields.io/pypi/v/treestat-cli.svg?label=PyPI)](https://pypi.org/project/treestat-cli/)
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)

Command-line tool that shows **source file counts per directory and language** in a tree view.

- **Flexible filtering**: language presets via `--lang` or custom extensions via `--ext`.
- **Configurable counting**: only direct files in each directory (`direct`) or full subtree aggregation (`tree`).
- **Script‑friendly output**: human‑readable text or stable JSON for CI, dashboards, and scripts.

---

## βš™οΈ Installation

The recommended way to install `treestat` is via **uv** so that it is managed as a Python tool:

```bash
uv tool install treestat-cli
```

Or install from PyPI:

```bash
pip install treestat-cli
```

You can also install the native Rust binary from crates.io:

```bash
cargo install treestat
```

---

## πŸš€ Usage

Count C/C++ files up to depth 3 under the current directory:

```bash
treestat . --lang c,cpp --max-depth 3
```

Example (text) output:

```text
all file statistics (Tree View):
============================================================
llvm-project/ (52970 files)
β”œβ”€β”€ bolt/ (241 files)
β”œβ”€β”€ clang/ (18264 files)
β”œβ”€β”€ clang-tools-extra/ (3003 files)
β”œβ”€β”€ compiler-rt/ (3417 files)
β”œβ”€β”€ cross-project-tests/ (228 files)
β”œβ”€β”€ flang/ (665 files)
β”œβ”€β”€ libc/ (1959 files)
β”œβ”€β”€ libclc/ (248 files)
β”œβ”€β”€ libcxx/ (9179 files)
β”œβ”€β”€ libcxxabi/ (105 files)
β”œβ”€β”€ libunwind/ (43 files)
β”œβ”€β”€ lld/ (219 files)
β”œβ”€β”€ lldb/ (4765 files)
β”œβ”€β”€ llvm/ (6866 files)
β”œβ”€β”€ llvm-libgcc/ (2 files)
β”œβ”€β”€ mlir/ (1873 files)
β”œβ”€β”€ openmp/ (744 files)
β”œβ”€β”€ polly/ (893 files)
β”œβ”€β”€ pstl/ (97 files)
β”œβ”€β”€ third-party/ (154 files)
└── utils/ (5 files)
============================================================
Total matching files: 52970
Directories containing files: 6516
Languages (Top 5): c=12000,c++=38000,python=2970
```

To get JSON for automation:

```bash
treestat . --lang rust --format json --json-pretty
```

---

## πŸ“š CLI reference

```text
treestat [PATH] [OPTIONS]
```

- `PATH`: target directory (default: `.`)
- `--lang <LANG[,LANG...]>`: language preset(s) from embedded Linguist data (repeatable, aliases supported)
- `--ext <LIST>`: custom extensions (comma-separated, supports `rs` or `.rs`)
- `--headers <include|exclude|only>`: header-file policy (default: `include`)
- `--count-mode <direct|tree>`: counting mode (default: `tree`)
- `--max-depth <N>`: maximum directory depth (root=0)
- `--min-count <N>`: hide directories below this count
- `--show-empty`: include `0 files` directories
- `--follow-symlinks`: follow symlinks (default: disabled)
- `--exclude <PATTERN>`: exclude path pattern (repeatable)
- `--no-gitignore`: disable `.gitignore`-based filtering
- `--hidden`: include hidden files/directories
- `--format <text|json>`: output format (default: `text`)
- `--json-pretty`: pretty-print JSON

---

## βš–οΈ Default behavior

- `.gitignore` patterns are **enabled by default**.
- Hidden entries are **excluded by default** unless `--hidden` is set.
- Common build/output directories are excluded by default:
  `.git`, `target`, `build`, `out`, `node_modules`, `third_party`, `dist`.
- `dirs_with_files` does **not** include the root directory.

---

## πŸ§ͺ Development

```bash
cargo fmt
cargo clippy --all-targets --all-features -- -D warnings
cargo test
```

---

## πŸ“œ License

MIT License. See `LICENSE` for details.

---

## 🀝 Contributing

Contributions are welcome! Feel free to open an issue or submit a pull request.

---

## πŸ“ž Support

- GitHub Issues: [Report a bug]https://github.com/chouzz/treestat/issues
- GitHub README: [View the latest docs]https://github.com/chouzz/treestat#readme