fix: tweaking the default table layout
This commit is contained in:
parent
e59d489a06
commit
2327417842
2 changed files with 26 additions and 9 deletions
|
@ -41,10 +41,5 @@ namespace MfGames.ToolBuilder.Tables
|
||||||
/// Indicates tht the output should be written as comma-separated values.
|
/// Indicates tht the output should be written as comma-separated values.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Csv,
|
Csv,
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Duplicates ConsoleTableBuilderFormat.Default.
|
|
||||||
/// </summary>
|
|
||||||
Full = Default,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,7 +104,7 @@ namespace MfGames.ToolBuilder.Tables
|
||||||
|
|
||||||
this.tableFormatOption = new Option<string>(
|
this.tableFormatOption = new Option<string>(
|
||||||
"--table-format",
|
"--table-format",
|
||||||
() => nameof(TableFormatType.Minimal),
|
() => nameof(TableFormatType.Default),
|
||||||
tableFormatDescription)
|
tableFormatDescription)
|
||||||
{
|
{
|
||||||
ArgumentHelpName = "format",
|
ArgumentHelpName = "format",
|
||||||
|
@ -402,9 +402,31 @@ namespace MfGames.ToolBuilder.Tables
|
||||||
TableFormatType tableFormat)
|
TableFormatType tableFormat)
|
||||||
{
|
{
|
||||||
// Build the table from options.
|
// Build the table from options.
|
||||||
ConsoleTableBuilder builder = ConsoleTableBuilder
|
ConsoleTableBuilder builder = ConsoleTableBuilder.From(this.table);
|
||||||
.From(this.table)
|
|
||||||
.WithFormat((ConsoleTableBuilderFormat)tableFormat);
|
// 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.
|
// We default to aligning numerical columns to the right.
|
||||||
bool noAlign =
|
bool noAlign =
|
||||||
|
|
Reference in a new issue