TreeCreator 1.0.8
dotnet add package TreeCreator --version 1.0.8
NuGet\Install-Package TreeCreator -Version 1.0.8
<PackageReference Include="TreeCreator" Version="1.0.8" />
<PackageVersion Include="TreeCreator" Version="1.0.8" />
<PackageReference Include="TreeCreator" />
paket add TreeCreator --version 1.0.8
#r "nuget: TreeCreator, 1.0.8"
#addin nuget:?package=TreeCreator&version=1.0.8
#tool nuget:?package=TreeCreator&version=1.0.8
TreeCreator
A flexible and powerful .NET library for generating directory tree representations with advanced filtering capabilities. Similar to the classic tree
command-line utility but with more configuration options and a fluent API.
Features
- Generate ASCII/text tree representations of directory structures
- Exclude specific directories or file extensions
- Include only specific directories or file extensions
- Fluent API for easy configuration
- Customizable output format
- Support for modern .NET applications
Installation
Package Manager
Install-Package TreeCreator
.NET CLI
dotnet add package TreeCreator
PackageReference
<PackageReference Include="TreeCreator" Version="1.0.3" />
Quick Start
using TreeCreator;
// Create a new tree generator
var treeCreator = TreeCreatorFactory.Create();
// Generate a tree for the specified directory
var result = treeCreator.Generate("C:/Projects/MyProject");
// Display the tree
Console.WriteLine(result.ToString());
Usage Examples
Basic Usage
using TreeCreator;
// Create a new tree generator
var treeCreator = TreeCreatorFactory.Create();
// Generate a tree for the specified directory
var result = treeCreator.Generate("C:/Projects/MyProject");
// Display the tree
Console.WriteLine(result.ToString());
Excluding Directories
var treeCreator = TreeCreatorFactory.Create()
.ExcludeDirectories("bin", "obj", "node_modules", ".git");
var result = treeCreator.Generate("C:/Projects/MyProject");
Excluding File Extensions
var treeCreator = TreeCreatorFactory.Create()
.ExcludeExtensions(".dll", ".exe", ".pdb");
var result = treeCreator.Generate("C:/Projects/MyProject");
Including Only Specific Directories
var treeCreator = TreeCreatorFactory.Create()
.IncludeOnlyDirectories("src", "tests", "docs");
var result = treeCreator.Generate("C:/Projects/MyProject");
Including Only Specific File Extensions
var treeCreator = TreeCreatorFactory.Create()
.IncludeOnlyExtensions(".cs", ".csproj", ".md");
var result = treeCreator.Generate("C:/Projects/MyProject");
Combining Multiple Filters
var treeCreator = TreeCreatorFactory.Create()
.ExcludeDirectories("bin", "obj")
.IncludeOnlyExtensions(".cs", ".csproj");
var result = treeCreator.Generate("C:/Projects/MyProject");
Working with the Result
var treeCreator = TreeCreatorFactory.Create();
var result = treeCreator.Generate("C:/Projects/MyProject");
// Get the string representation
string treeString = result.ToString();
// Access individual lines
foreach (var line in result.Lines)
{
Console.WriteLine($"Line: {line}");
}
// Save to a file
File.WriteAllText("tree-output.txt", result.ToString());
API Reference
TreeCreatorFactory
Static factory for creating instances of ITreeCreator
.
public static class TreeCreatorFactory
{
public static ITreeCreator Create();
}
ITreeCreator
Interface defining the core functionality of the tree generator.
public interface ITreeCreator
{
ITreeCreator ExcludeDirectories(params string[] directoryNames);
ITreeCreator ExcludeExtensions(params string[] extensions);
ITreeCreator IncludeOnlyDirectories(params string[] directoryNames);
ITreeCreator IncludeOnlyExtensions(params string[] extensions);
TreeResult Generate(string? rootPath);
}
TreeResult
Represents the result of a directory tree generation operation.
public class TreeResult
{
public TreeResult(string rootPath);
public void AppendLine(string line);
public IReadOnlyList<string> Lines { get; }
public override string ToString();
}
TreeCreatorOptions
Configuration options for the tree generator.
public class TreeCreatorOptions
{
public HashSet<string> ExcludedDirectories { get; }
public HashSet<string> ExcludedExtensions { get; }
public HashSet<string> IncludedDirectories { get; }
public HashSet<string> IncludedExtensions { get; }
}
Example Output
C:/Projects/MyProject/
├── src/
│ ├── TreeCreator/
│ │ ├── DefaultTreeCreator.cs
│ │ ├── Interfaces/
│ │ │ └── ITreeCreator.cs
│ │ ├── Models/
│ │ │ ├── TreeCreatorOptions.cs
│ │ │ └── TreeResult.cs
│ │ └── TreeCreatorFactory.cs
│ └── TreeCreator.csproj
├── tests/
│ ├── TreeCreator.Tests/
│ │ ├── DefaultTreeCreatorTests.cs
│ │ └── TreeResultTests.cs
│ └── TreeCreator.Tests.csproj
└── README.md
Requirements
- .NET 8.0 or higher
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
Acknowledgments
- Inspired by the classic Unix/Linux
tree
command - Developed with love for the .NET community
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
- Initial release of TreeCreator.