private static StringTableBuilder CreateComplexTableBuilderHAlignMixedColumns() { var table = new StringTableBuilder(); table.AddColumn("col1").SetHAlignRight(); table.AddColumn("col2").SetHAlignRight(); table.AddColumn("col3").SetHAlignRight(); var row = table.AddRow(); row.SetCell("col1", "foo"); row.SetCell("col2", "foobarbaz"); row.SetCell("col3", "this is a\nmulti-line\nstring"); row = table.AddRow().SetHAlignLeft(); row.SetCell("col1", "foobar"); row.SetCell("col2", "e\nee\neee\ne").SetHAlignRight(); row.SetCell("col3", "f"); row = table.AddRow(); row.SetCell("col1", "foobarbaz"); row.SetCell("col2", "h"); row.SetCell("col3", "i"); return(table); }
private static StringTableBuilder CreateComplexTableBuilderWithMixedNewLines() { var table = new StringTableBuilder(); table.AddColumn("col1"); table.AddColumn("col2"); table.AddColumn("col3"); var row = table.AddRow(); row.SetCell("col1", "foo"); row.SetCell("col2", "foobarbaz"); row.SetCell("col3", "this is a\r\nmulti-line\nstring"); row = table.AddRow(); row.SetCell("col1", "foobar"); row.SetCell("col2", "e\r\nee\neee\r\ne"); row.SetCell("col3", "f"); row = table.AddRow(); row.SetCell("col1", "foobarbaz"); row.SetCell("col2", "h"); row.SetCell("col3", "i"); return(table); }
private static StringTableBuilder CreateSimpleTableBuilder() { var table = new StringTableBuilder(); table.AddColumn("col1"); table.AddColumn("col2"); table.AddColumn("col3"); var row = table.AddRow(); row.SetCell("col1", "a"); row.SetCell("col2", "b"); row.SetCell("col3", "c"); row = table.AddRow().SetHAlignLeft(); row.SetCell("col1", "d"); row.SetCell("col2", "e"); row.SetCell("col3", "f"); row = table.AddRow(); row.SetCell("col1", "g"); row.SetCell("col2", "h"); row.SetCell("col3", "i"); return(table); }
public void AddEmptyRow() { var table = new StringTableBuilder(); table.AddColumn("col1"); table.AddColumn("col2"); table.AddColumn("col3"); var row = table.AddRow(); row.SetCell("col1", "a"); row.SetCell("col2", "b"); row.SetCell("col3", "c"); table.AddEmptyRow(); row = table.AddRow(); row.SetCell("col1", "d"); row.SetCell("col2", "e"); row.SetCell("col3", "f"); var output = table.ToString(); Console.WriteLine(output); var expectedOutput = "abc" + s_nl + " " + s_nl + "def"; Assert.Equal(expectedOutput, output); }
private static string UsageParameters(Command command, string commandName) { var builder = new StringBuilder(); builder.AppendLine(commandName == null ? "Parameters:" : $"{commandName} parameters:"); var paramNames = command.Parameters.Keys.OrderBy(s => s).ToList(); var table = new StringTableBuilder(); table.AddColumn("space0"); table.AddColumn("name"); table.AddColumn("space1"); table.AddColumn("alias"); table.AddColumn("space2"); table.AddColumn("default-value"); table.AddColumn("space3"); table.AddColumn("type"); table.AddColumn("space4"); table.AddColumn("description"); var headerRow = table.AddRow(); headerRow.SetCell("space0", " "); headerRow.SetCell("name", "name"); headerRow.SetCell("space1", " "); headerRow.SetCell("alias", "alias"); headerRow.SetCell("space2", " "); headerRow.SetCell("default-value", "default-value"); headerRow.SetCell("space3", " "); headerRow.SetCell("type", "type"); headerRow.SetCell("space4", " "); headerRow.SetCell("description", "description"); foreach (var paramName in paramNames) { var param = command.Parameters[paramName]; var row = table.AddRow(); row.SetCell("space0", " "); row.SetCell("name", $"--{param.Name}"); row.SetCell("space1", " "); row.SetCell("alias", $"{AliasKey(param)}"); row.SetCell("space2", " "); row.SetCell("default-value", param.Optional ? $"{param.DefaultValue}" : ""); row.SetCell("space3", " "); row.SetCell("type", $"{param.Type.Name}"); row.SetCell("space4", " "); row.SetCell("description", $"{param.Description}"); } builder.Append(table.ToString()); return(builder.ToString()); }
private string UsageCommands(string[] commandNames) { var table = new StringTableBuilder(); table.AddColumn("col1"); table.AddColumn("col2"); foreach (var commandName in commandNames) { var command = _commands[commandName]; var row = table.AddRow(); row.SetCell("col1", $" {command.Name}"); row.SetCell("col2", $" {command.Description}"); } return(table.ToString()); }
private static string UsageFooter() { var table = new StringTableBuilder().SetInnerCellColumnPadding(1); table.AddColumn("col1"); table.AddColumn("col2"); table.AddColumn("col3"); var row = table.AddRow(); row.SetCell("col1", "<parameters>"); row.SetCell("col2", ":="); row.SetCell("col3", "<p1-key> <p1-value> ... <pN-key> <pN-value>"); row = table.AddRow(); row.SetCell("col1", "<p-key>"); row.SetCell("col2", ":="); row.SetCell("col3", "-<p-alias>|--<p-name>"); return(table.ToString()); }