summaryrefslogtreecommitdiff
path: root/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/TrainerCommand.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/SMAPI.Mods.ConsoleCommands/Framework/Commands/TrainerCommand.cs')
-rw-r--r--src/SMAPI.Mods.ConsoleCommands/Framework/Commands/TrainerCommand.cs12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/TrainerCommand.cs b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/TrainerCommand.cs
index 466b8f6e..8f0d89ba 100644
--- a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/TrainerCommand.cs
+++ b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/TrainerCommand.cs
@@ -66,7 +66,8 @@ namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands
/// <param name="data">The data to display.</param>
/// <param name="header">The table header.</param>
/// <param name="getRow">Returns a set of fields for a data value.</param>
- protected string GetTableString<T>(IEnumerable<T> data, string[] header, Func<T, string[]> getRow)
+ /// <param name="rightAlign">True to right-align the data, false for left-align. Default false.</param>
+ protected string GetTableString<T>(IEnumerable<T> data, string[] header, Func<T, string[]> getRow, bool rightAlign = false)
{
// get table data
int[] widths = header.Select(p => p.Length).ToArray();
@@ -92,6 +93,15 @@ namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands
};
lines.AddRange(rows);
+ if (rightAlign)
+ {
+ return string.Join(
+ Environment.NewLine,
+ lines.Select(line => string.Join(" | ", line.Select((field, i) => field.PadLeft(widths[i], ' ')).ToArray())
+ )
+ );
+ }
+
return string.Join(
Environment.NewLine,
lines.Select(line => string.Join(" | ", line.Select((field, i) => field.PadRight(widths[i], ' ')).ToArray())