How to create tree based terminal app in .net core
·Feb 11, 2023·
1 min read
Tree is used to render hierarchical data on the terminal. Spectre.Console is a .NET library which is used to create console applications. Spectre.Console is rendering the tree on the terminal.
>dotnet new console -o cliapptree
Install Nuget Package:-
>dotnet add package Spectre.Console
var root = new Tree("[darkorange3_1]Root[/]")
Add some nodes:-
var foo = root.AddNode("[magenta]Tree[/]");
Add calendar events:-
AddCalendarEvent(2023, 12, 12) .HideHeader() .BorderStyle(Style.Parse("Magenta3")));
Render the tree on Console:-
To render a Tree, create a tree object, and add some styling code according to the app's requirement. Complete the app by passing the tree dependent calendar to a console's Write method. The full source code is on GitHub.