VOOZH about

URL: https://www.nuget.org/packages/tababular/

⇱ NuGet Gallery | Tababular 4.3.0




👁 Image
Tababular 4.3.0

dotnet add package Tababular --version 4.3.0
 
 
NuGet\Install-Package Tababular -Version 4.3.0
 
 
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Tababular" Version="4.3.0" />
 
 
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Tababular" Version="4.3.0" />
 
Directory.Packages.props
<PackageReference Include="Tababular" />
 
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Tababular --version 4.3.0
 
 
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Tababular, 4.3.0"
 
 
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Tababular@4.3.0
 
 
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Tababular&version=4.3.0
 
Install as a Cake Addin
#tool nuget:?package=Tababular&version=4.3.0
 
Install as a Cake Tool
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Tababular

A simple .NET monospace text table formatting library for .NET 4.5 and .NET Standard 1.6.

You can use it if you are standing with a bunch of objects or dictionaries in your hand, and you wish for them to become as nice as this:

+-------------+--------------+-------------+
| FirstColumn | SecondColumn | ThirdColumn |
+-------------+--------------+-------------+
| r1 | hej | hej igen |
+-------------+--------------+-------------+
| r2 | hej | hej igen |
+-------------+--------------+-------------+

This can easily be achieved by newing up the TableFormatter like this:

var formatter = new TableFormatter();

and then you call an appropriate Format*** method on it, e.g. FormatObjects:

var objects = new[]
{
	new {FirstColumn = "r1", SecondColumn = "hej", ThirdColumn = "hej igen"},
	new {FirstColumn = "r2", SecondColumn = "hej", ThirdColumn = "hej igen"},
};

var text = tableFormatter.FormatObjects(objects);

Console.WriteLine(text);

which will result in the table shown above.

For now, Tababular does not support that much stuff - but one nice thing about it is that it will properly format lines in cells, so that e.g.

var objects = new[]
{
	new { MachineName = "ctxtest01", Ip = "10.0.0.10", Ports = new[] {80, 8080, 9090}},
	new { MachineName = "ctxtest02", Ip = "10.0.0.11", Ports = new[] {80, 5432}}
};

var text = new TableFormatter().FormatObjects(objects);

Console.WriteLine(text);

becomes nice like this:

+-----------+-------------+-------+
| Ip | MachineName | Ports |
+-----------+-------------+-------+
| 10.0.0.10 | ctxtest01 | 80 |
| | | 8080 |
| | | 9090 |
+-----------+-------------+-------+
| 10.0.0.11 | ctxtest02 | 80 |
| | | 5432 |
+-----------+-------------+-------+

which looks pretty neat if you ask me.

Formatting different things

Tababular can format different things, which at the moment includes:

  • Objects: formatter.FormatObjects(objects)
  • Dictionaries: formatter.FormatDictionaries(dictionaries)
  • JSON: formatter.FormatJson(jsonText)

More niceness

What about longs texts? Consider this example where the "Comments" column can be used to supply arbitrarily long texts:

var objects = new[]
{
	new {MachineName = "ctxtest01", Ip = "10.0.0.10", Ports = new[] {80, 8080, 9090}, Comments = ""},
	new {MachineName = "ctxtest02", Ip = "10.0.0.11", Ports = new[] {5432},
		Comments = @"This bad boy hosts our database and a couple of internal jobs."}
};

var text = new TableFormatter().FormatObjects(objects);

In this case, the resulting table would look like this:

+----------------------------------------------------------------+-----------+-------------+-------+
| Comments | Ip | MachineName | Ports |
+----------------------------------------------------------------+-----------+-------------+-------+
| | 10.0.0.10 | ctxtest01 | 80 |
| | | | 8080 |
| | | | 9090 |
+----------------------------------------------------------------+-----------+-------------+-------+
| This bad boy hosts our database and a couple of internal jobs. | 10.0.0.11 | ctxtest02 | 5432 |
+----------------------------------------------------------------+-----------+-------------+-------+

which might be fine, but since the texts can be even longer than this, it might end up being a problem.

Fear not! We can supply a small hint to the table formatter like this:

var hints = new Hints { MaxTableWidth = 80 };
var formatter = new TableFormatter(hints);

and then when we

var text = formatter.FormatObjects(objects);

it will look like this:

+------------------------------------------------+-----------+-------------+-------+
| Comments | Ip | MachineName | Ports |
+------------------------------------------------+-----------+-------------+-------+
| | 10.0.0.10 | ctxtest01 | 80 |
| | | | 8080 |
| | | | 9090 |
+------------------------------------------------+-----------+-------------+-------+
| This bad boy hosts our database and a couple | 10.0.0.11 | ctxtest02 | 5432 |
| of internal jobs. | | | |
+------------------------------------------------+-----------+-------------+-------+

and the table will never become wider than at most 80 characters. Objectively speaking, this is actually freaking awesome.

License

The MIT License (MIT)

Product Versions Compatible and additional computed target framework versions.
.NET net5.0 net5.0 was computed.  net5.0-windows net5.0-windows was computed.  net6.0 net6.0 was computed.  net6.0-android net6.0-android was computed.  net6.0-ios net6.0-ios was computed.  net6.0-maccatalyst net6.0-maccatalyst was computed.  net6.0-macos net6.0-macos was computed.  net6.0-tvos net6.0-tvos was computed.  net6.0-windows net6.0-windows was computed.  net7.0 net7.0 was computed.  net7.0-android net7.0-android was computed.  net7.0-ios net7.0-ios was computed.  net7.0-maccatalyst net7.0-maccatalyst was computed.  net7.0-macos net7.0-macos was computed.  net7.0-tvos net7.0-tvos was computed.  net7.0-windows net7.0-windows was computed.  net8.0 net8.0 was computed.  net8.0-android net8.0-android was computed.  net8.0-browser net8.0-browser was computed.  net8.0-ios net8.0-ios was computed.  net8.0-maccatalyst net8.0-maccatalyst was computed.  net8.0-macos net8.0-macos was computed.  net8.0-tvos net8.0-tvos was computed.  net8.0-windows net8.0-windows was computed.  net9.0 net9.0 was computed.  net9.0-android net9.0-android was computed.  net9.0-browser net9.0-browser was computed.  net9.0-ios net9.0-ios was computed.  net9.0-maccatalyst net9.0-maccatalyst was computed.  net9.0-macos net9.0-macos was computed.  net9.0-tvos net9.0-tvos was computed.  net9.0-windows net9.0-windows was computed.  net10.0 net10.0 was computed.  net10.0-android net10.0-android was computed.  net10.0-browser net10.0-browser was computed.  net10.0-ios net10.0-ios was computed.  net10.0-maccatalyst net10.0-maccatalyst was computed.  net10.0-macos net10.0-macos was computed.  net10.0-tvos net10.0-tvos was computed.  net10.0-windows net10.0-windows was computed. 
.NET Core netcoreapp2.0 netcoreapp2.0 was computed.  netcoreapp2.1 netcoreapp2.1 was computed.  netcoreapp2.2 netcoreapp2.2 was computed.  netcoreapp3.0 netcoreapp3.0 was computed.  netcoreapp3.1 netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 netstandard2.0 is compatible.  netstandard2.1 netstandard2.1 was computed. 
.NET Framework net461 net461 was computed.  net462 net462 was computed.  net463 net463 was computed.  net47 net47 was computed.  net471 net471 was computed.  net472 net472 was computed.  net48 net48 was computed.  net481 net481 was computed. 
MonoAndroid monoandroid monoandroid was computed. 
MonoMac monomac monomac was computed. 
MonoTouch monotouch monotouch was computed. 
Tizen tizen40 tizen40 was computed.  tizen60 tizen60 was computed. 
Xamarin.iOS xamarinios xamarinios was computed. 
Xamarin.Mac xamarinmac xamarinmac was computed. 
Xamarin.TVOS xamarintvos xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Tababular:

Package Downloads
Testy

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
4.3.0 14,562 8/21/2024
4.2.0 781 8/1/2024
4.1.0 618,618 12/28/2021
4.0.0 17,519 7/27/2020
3.0.1 36,542 2/20/2019
3.0.0 2,824 11/15/2018
3.0.0-b02 1,437 5/8/2018
3.0.0-b01 1,405 5/7/2018
2.0.0 2,790 7/28/2017
2.0.0-b01 1,292 4/26/2017
1.0.6 2,441 6/14/2016
1.0.5 1,572 2/23/2016
1.0.4 1,394 2/23/2016
1.0.3 1,436 2/21/2016
1.0.2 1,531 2/21/2016
1.0.1 1,465 2/20/2016
1.0.0 1,511 2/20/2016
1.0.0-a2 1,270 2/20/2016
1.0.0-a1 1,285 2/20/2016