Files
tree-generator/Releases/v1.0.0/docs/QUICKSTART.md
Agent fbad6a4647 release: v1.0.0 - 目录树生成脚本 Python 版本正式发布
- 更新为 Python 3.8+ 实现(tree_gen.py)
- 8 个功能全部通过(F013-F020)
- 更新 RELEASE.md、QUICKSTART.md 为 Python 版本
- 移除旧 Bash 版本文件(tree.sh)
- 添加架构设计文档(t023-architecture-design.md)
2026-05-16 17:35:55 +08:00

109 lines
2.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# tree_gen.py 快速入门
> 版本 1.0.0 | Python 目录树生成工具 | Windows 平台
## 1 分钟上手
### 环境检查
```cmd
python --version
```
确保显示 Python 3.8 或更高版本。
### 基本使用
```cmd
:: 生成当前目录的树
python tree_gen.py
:: 生成指定目录的树
python tree_gen.py C:\Users\Documents\project
:: 生成文件树(-f 参数)
python tree_gen.py -f .
:: 限制深度为 2 层
python tree_gen.py -d 2 .
:: 保存到指定文件
python tree_gen.py -o my-tree.md .
:: 仅显示目录树
python tree_gen.py -D .
:: 使用自定义忽略配置
python tree_gen.py -i my_ignore.txt .
```
### 输出示例
```
my-project/
├── src/
│ ├── main.py
│ ├── utils/
│ │ ├── helper.py
│ │ └── config.py
│ └── models/
│ └── user.py
├── tests/
│ ├── test_main.py
│ └── test_utils.py
├── README.md
└── requirements.txt
==================================================
目录数: 4
文件数: 7
总大小: 12.3 KB
==================================================
```
## 常用场景
| 场景 | 命令 |
|------|------|
| 查看项目结构 | `python tree_gen.py C:\Projects\my-app` |
| 生成文档用树 | `python tree_gen.py -f -o README-tree.md .` |
| 只看前 2 层 | `python tree_gen.py -d 2 .` |
| 仅显示目录 | `python tree_gen.py -D .` |
| 排除日志文件 | 创建 `.treeignore`,写入 `*.log` |
## 自定义忽略规则
在目标目录创建 `.treeignore`
```text
# .treeignore
*.log
tmp
coverage
*.bak
.env
```
## 命令行选项速查
| 选项 | 说明 | 默认值 |
|------|------|--------|
| `path` | 目标目录 | 当前目录 |
| `-o <文件>` | Markdown 输出文件 | `tree_output.md` |
| `-d <N>` | 最大深度 | 无限制 |
| `-f` | 仅文件树 | 关闭 |
| `-D` | 仅目录树 | 关闭 |
| `-i <文件>` | 忽略配置文件 | 自动检测 |
| `-h` | 帮助 | — |
## 退出码
| 码 | 含义 |
|----|------|
| 0 | 成功 |
| 1 | 参数错误(路径不存在等) |
---
详细文档请查看 [README.md](README.md)