A Python tool to generate directory structures with customizable filtering (.gitignore support) and output formats (text/JSON).
- Recursive directory traversal with depth control
- Flexible filtering:
.gitignoresupport (optional)- Custom ignore lists
- File inclusion/exclusion toggle
- Multiple output formats:
- text
- JSON
- CLI interface
Basic command
python app/main.py --root_dir /path/to/directory
| Argument | Description | Default | Required |
|---|---|---|---|
--root_dir |
Root directory to scan | - | Yes |
--max_depth |
Maximum recursion depth | None | No |
--include_files |
Include files in output | True | No |
--gitignore_path |
Custom path to .gitignore |
.gitignore | No |
--output_type |
Output format (str or json) |
str | No |
-
Simple tree (text output):
python main.py --root_dir ./project
-
JSON output with depth limit:
python main.py --root_dir ./project --max_depth 2 --output_type json
-
With gitignore support:
python main.py --root_dir ./project --gitignore_path .gitignore True
Text format:
readme-tree\
├── app\
│ ├── scripts\
│ │ ├── input_parser.py
│ │ └── tree_generator.py
│ └── main.py
├── LICENSE
└── README.md
JSON format:
{
"readme-tree": {
"app": {
"scripts": {
"input_parser.py": null,
"tree_generator.py": null
},
"main.py": null
},
"LICENSE": null,
"README.md": null
}
}