From 23274178428f7cf01e2ea099748f5028f529fdb9 Mon Sep 17 00:00:00 2001 From: "Dylan R. E. Moonfire" Date: Sun, 12 Sep 2021 01:03:50 -0500 Subject: [PATCH] fix: tweaking the default table layout --- .../Tables/TableFormatType.cs | 5 ---- .../Tables/TableToolService.cs | 30 ++++++++++++++++--- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/src/MfGames.ToolBuilder/Tables/TableFormatType.cs b/src/MfGames.ToolBuilder/Tables/TableFormatType.cs index 9afd828..2f0de46 100644 --- a/src/MfGames.ToolBuilder/Tables/TableFormatType.cs +++ b/src/MfGames.ToolBuilder/Tables/TableFormatType.cs @@ -41,10 +41,5 @@ namespace MfGames.ToolBuilder.Tables /// Indicates tht the output should be written as comma-separated values. /// Csv, - - /// - /// Duplicates ConsoleTableBuilderFormat.Default. - /// - Full = Default, } } diff --git a/src/MfGames.ToolBuilder/Tables/TableToolService.cs b/src/MfGames.ToolBuilder/Tables/TableToolService.cs index 52dd2a4..b545162 100644 --- a/src/MfGames.ToolBuilder/Tables/TableToolService.cs +++ b/src/MfGames.ToolBuilder/Tables/TableToolService.cs @@ -104,7 +104,7 @@ namespace MfGames.ToolBuilder.Tables this.tableFormatOption = new Option( "--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.DividerY, ' ' }, + }) + .WithHeaderCharMapDefinition( + new Dictionary + { + { HeaderCharMapPositions.BottomCenter, '+' }, + { HeaderCharMapPositions.Divider, ' ' }, + { HeaderCharMapPositions.BorderBottom, '-' }, + }); + } + else + { + builder.WithFormat((ConsoleTableBuilderFormat)tableFormat); + } // We default to aligning numerical columns to the right. bool noAlign =