TreeGen is a command-line tool written in C# that generates a visual directory tree. It displays the structure of a directory in a tree-like format, with options to customize the output.
RP Tree, a directory tree generator
- Generate a full directory tree starting from a specified directory.
- Option to display only directories (
-d/--dir-only). - Save the tree to a file (
-o/--output-file). - Display help (
-h/--help) and version (-v/--version) information. - Simple and intuitive CLI interface.
dotnet tool install --global TreeGenRun:
treegen --help- .NET 8 SDK or later.
- Clone the repository:
git clone https://github.com/your-username/TreeGen.git cd TreeGen - Build the project:
dotnet build
- Run the application:
dotnet run -- [options] [ROOT_DIR]
To run treegen without dotnet run:
- Publish the tool:
Replace
dotnet publish -c Release -r win-x64 --self-contained -o ./publish
win-x64withlinux-x64orosx-x64for other platforms. - Run from the publish folder:
./publish/treegen -h
To run treegen from any directory:
- Update
TreeGen.csprojto include:<PropertyGroup> <PackAsTool>true</PackAsTool> <ToolCommandName>treegen</ToolCommandName> <PackageOutputPath>./nupkg</PackageOutputPath> </PropertyGroup>
- Pack and install:
dotnet pack dotnet tool install --global --add-source ./nupkg TreeGen
- Run:
treegen --help
The command tree may conflict with the built-in Windows tree command. Use treegen (the executable name) or dotnet run -- [options] to run TreeGen:
dotnet run -- -d ./test_dir
./publish/treegen -vusage: treegen [-h] [-v] [-d] [-o [OUTPUT_FILE]] [ROOT_DIR]
RP Tree, a directory tree generator
positional arguments:
ROOT_DIR Generate a full directory tree starting at ROOT_DIR
optional arguments:
-h, --help show this help message and exit
-v, --version show program's version number and exit
-d, --dir-only Generate a Directory-only Tree
-o [OUTPUT_FILE], --output-file [OUTPUT_FILE]
Generate a full directory tree and save it to a file.
Thanks for using RP Tree!-
Generate a tree for the current directory:
treegen
Output:
. ├── file1.txt ├── folder1 │ └── file2.txt └── folder2 └── file3.txt -
Generate a directory-only tree:
treegen -d ./test_dir
Output:
./test_dir ├── folder1 └── folder2 -
Save the tree to a file:
treegen -o tree.txt ./test_dir
Output: Creates
tree.txtwith the tree structure. -
Show version:
treegen -v
Output:
RP Tree version 1.0.0
Contributions are welcome! Please:
- Fork the repository.
- Create a feature branch:
git checkout -b feature/your-feature
- Commit your changes:
git commit -m "Add your feature" - Push to the branch:
git push origin feature/your-feature
- Open a Pull Request.
This project is licensed under the MIT License. See the LICENSE file for details.
- Inspired by the rptree Python project.
- Built with System.CommandLine.