fix: tweaking the default table layout

This commit is contained in:
Dylan R. E. Moonfire 2021-09-12 01:03:50 -05:00
parent e59d489a06
commit 2327417842
2 changed files with 26 additions and 9 deletions

View file

@ -41,10 +41,5 @@ namespace MfGames.ToolBuilder.Tables
/// Indicates tht the output should be written as comma-separated values.
/// </summary>
Csv,
/// <summary>
/// Duplicates ConsoleTableBuilderFormat.Default.
/// </summary>
Full = Default,
}
}

View file

@ -104,7 +104,7 @@ namespace MfGames.ToolBuilder.Tables
this.tableFormatOption = new Option<string>(
"--table-format",
() => nameof(TableFormatType.Minimal),
() => nameof(TableFormatType.Default),
tableFormatDescription)
{
ArgumentHelpName = "format",
@ -402,9 +402,31 @@ namespace MfGames.ToolBuilder.Tables
TableFormatType tableFormat)
{
// Build the table from options.
ConsoleTableBuilder builder = ConsoleTableBuilder
.From(this.table)
.WithFormat((ConsoleTableBuilderFormat)tableFormat);
ConsoleTableBuilder builder = ConsoleTableBuilder.From(this.table);
// Figure out formatting.
if (tableFormat == TableFormatType.Default)
{
// Default is mostly like ConsoleTableExt but there is a separator
// between the headers because it makes it harder to parse.
builder
.WithCharMapDefinition(
new Dictionary<CharMapPositions, char>
{
{ CharMapPositions.DividerY, ' ' },
})
.WithHeaderCharMapDefinition(
new Dictionary<HeaderCharMapPositions, char>
{
{ HeaderCharMapPositions.BottomCenter, '+' },
{ HeaderCharMapPositions.Divider, ' ' },
{ HeaderCharMapPositions.BorderBottom, '-' },
});
}
else
{
builder.WithFormat((ConsoleTableBuilderFormat)tableFormat);
}
// We default to aligning numerical columns to the right.
bool noAlign =