From e429f6434bac1ff421dbe5f0e2fa09d58e9edf09 Mon Sep 17 00:00:00 2001 From: Patrik Svensson Date: Thu, 1 Oct 2020 12:46:40 +0200 Subject: [PATCH] Update examples --- .github/workflows/ci.yaml | 6 +-- examples/Borders/Borders.csproj | 1 + examples/Borders/Program.cs | 2 +- examples/Colors/Colors.csproj | 1 + examples/Columns/Columns.csproj | 1 + examples/Emojis/Emojis.csproj | 1 + examples/Emojis/Program.cs | 2 +- .../{Grid/Grid.csproj => Grids/Grids.csproj} | 1 + examples/{Grid => Grids}/Program.cs | 50 +++++++++---------- examples/Info/Info.csproj | 1 + examples/Info/Program.cs | 19 +++---- examples/Links/Links.csproj | 1 + examples/Links/Program.cs | 2 +- .../Panel.csproj => Panels/Panels.csproj} | 1 + examples/{Panel => Panels}/Program.cs | 0 examples/{Table => Tables}/Program.cs | 0 .../Table.csproj => Tables/Tables.csproj} | 1 + src/Spectre.Console.sln | 8 +-- 18 files changed, 54 insertions(+), 44 deletions(-) rename examples/{Grid/Grid.csproj => Grids/Grids.csproj} (94%) rename examples/{Grid => Grids}/Program.cs (97%) rename examples/{Panel/Panel.csproj => Panels/Panels.csproj} (93%) rename examples/{Panel => Panels}/Program.cs (100%) rename examples/{Table => Tables}/Program.cs (100%) rename examples/{Table/Table.csproj => Tables/Tables.csproj} (93%) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index c4edf31..554d4fc 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -65,9 +65,9 @@ jobs: run: | dotnet tool restore dotnet example info - dotnet example table - dotnet example grid - dotnet example panel + dotnet example tables + dotnet example grids + dotnet example panels dotnet example colors dotnet example emojis diff --git a/examples/Borders/Borders.csproj b/examples/Borders/Borders.csproj index 88c1cbb..a0950b5 100644 --- a/examples/Borders/Borders.csproj +++ b/examples/Borders/Borders.csproj @@ -4,6 +4,7 @@ Exe netcoreapp3.1 false + Borders Demonstrates the different kind of borders. diff --git a/examples/Borders/Program.cs b/examples/Borders/Program.cs index 526d833..4cba1c9 100644 --- a/examples/Borders/Program.cs +++ b/examples/Borders/Program.cs @@ -1,7 +1,7 @@ using Spectre.Console; using Spectre.Console.Rendering; -namespace Borders +namespace BordersExample { public static class Program { diff --git a/examples/Colors/Colors.csproj b/examples/Colors/Colors.csproj index 0b87dc9..4d5a1c5 100644 --- a/examples/Colors/Colors.csproj +++ b/examples/Colors/Colors.csproj @@ -4,6 +4,7 @@ Exe netcoreapp3.1 false + Colors Demonstrates how to use [yellow]c[/][red]o[/][green]l[/][blue]o[/][aqua]r[/][lime]s[/] in the console. diff --git a/examples/Columns/Columns.csproj b/examples/Columns/Columns.csproj index 73d3b88..3232517 100644 --- a/examples/Columns/Columns.csproj +++ b/examples/Columns/Columns.csproj @@ -4,6 +4,7 @@ Exe netcoreapp3.1 false + Columns Demonstrates how to render data into columns. diff --git a/examples/Emojis/Emojis.csproj b/examples/Emojis/Emojis.csproj index b0181c2..56d9359 100644 --- a/examples/Emojis/Emojis.csproj +++ b/examples/Emojis/Emojis.csproj @@ -4,6 +4,7 @@ Exe netcoreapp3.1 false + Emojis Demonstrates how to render emojis. diff --git a/examples/Emojis/Program.cs b/examples/Emojis/Program.cs index 85ab75f..f4662f0 100644 --- a/examples/Emojis/Program.cs +++ b/examples/Emojis/Program.cs @@ -1,6 +1,6 @@ using Spectre.Console; -namespace Emojis +namespace EmojiExample { public static class Program { diff --git a/examples/Grid/Grid.csproj b/examples/Grids/Grids.csproj similarity index 94% rename from examples/Grid/Grid.csproj rename to examples/Grids/Grids.csproj index d8f9a16..eb186e2 100644 --- a/examples/Grid/Grid.csproj +++ b/examples/Grids/Grids.csproj @@ -4,6 +4,7 @@ Exe netcoreapp3.1 false + Grids Demonstrates how to render grids in a console. diff --git a/examples/Grid/Program.cs b/examples/Grids/Program.cs similarity index 97% rename from examples/Grid/Program.cs rename to examples/Grids/Program.cs index 7e082d5..67c2ab4 100644 --- a/examples/Grid/Program.cs +++ b/examples/Grids/Program.cs @@ -1,25 +1,25 @@ -using Spectre.Console; - -namespace GridExample -{ - public static class Program - { - public static void Main() - { - AnsiConsole.WriteLine(); - AnsiConsole.MarkupLine("Usage: [grey]dotnet [blue]run[/] [[options]] [[[[--]] ...]]]][/]"); - AnsiConsole.WriteLine(); - - var grid = new Grid(); - grid.AddColumn(new GridColumn { NoWrap = true }); - grid.AddColumn(new GridColumn { NoWrap = true, Width = 2 }); - grid.AddColumn(); - grid.AddRow("Options:", "", ""); - grid.AddRow(" [blue]-h[/], [blue]--help[/]", "", "Show command line help."); - grid.AddRow(" [blue]-c[/], [blue]--configuration[/] ", "", "The configuration to run for."); - grid.AddRow(" [blue]-v[/], [blue]--verbosity[/] ", "", "Set the [grey]MSBuild[/] verbosity level."); - - AnsiConsole.Render(grid); - } - } -} +using Spectre.Console; + +namespace GridExample +{ + public static class Program + { + public static void Main() + { + AnsiConsole.WriteLine(); + AnsiConsole.MarkupLine("Usage: [grey]dotnet [blue]run[/] [[options]] [[[[--]] ...]]]][/]"); + AnsiConsole.WriteLine(); + + var grid = new Grid(); + grid.AddColumn(new GridColumn { NoWrap = true }); + grid.AddColumn(new GridColumn { NoWrap = true, Width = 2 }); + grid.AddColumn(); + grid.AddRow("Options:", "", ""); + grid.AddRow(" [blue]-h[/], [blue]--help[/]", "", "Show command line help."); + grid.AddRow(" [blue]-c[/], [blue]--configuration[/] ", "", "The configuration to run for."); + grid.AddRow(" [blue]-v[/], [blue]--verbosity[/] ", "", "Set the [grey]MSBuild[/] verbosity level."); + + AnsiConsole.Render(grid); + } + } +} diff --git a/examples/Info/Info.csproj b/examples/Info/Info.csproj index 5c16c82..c481f99 100644 --- a/examples/Info/Info.csproj +++ b/examples/Info/Info.csproj @@ -4,6 +4,7 @@ Exe netcoreapp3.1 false + Info Displays the capabilities of the current console. diff --git a/examples/Info/Program.cs b/examples/Info/Program.cs index 1b66b39..db3e758 100644 --- a/examples/Info/Program.cs +++ b/examples/Info/Program.cs @@ -1,6 +1,6 @@ using Spectre.Console; -namespace Info +namespace InfoExample { public static class Program { @@ -9,19 +9,20 @@ namespace Info var grid = new Grid() .AddColumn(new GridColumn().NoWrap().PadRight(4)) .AddColumn() - .AddRow("[b]:artist_palette: Color system[/]", $"{AnsiConsole.Capabilities.ColorSystem}") - .AddRow("[b]:nail_polish: Supports ansi?[/]", $"{GetEmoji(AnsiConsole.Capabilities.SupportsAnsi)}") - .AddRow("[b]:top_hat: Legacy console?[/]", $"{GetEmoji(AnsiConsole.Capabilities.LegacyConsole)}") - .AddRow("[b]:left_right_arrow: Buffer width[/]", $"{AnsiConsole.Console.Width}") - .AddRow("[b]:up_down_arrow: Buffer height[/]", $"{AnsiConsole.Console.Height}"); + .AddRow("[b]Color system[/]", $"{AnsiConsole.Capabilities.ColorSystem}") + .AddRow("[b]Supports ansi?[/]", $"{YesNo(AnsiConsole.Capabilities.SupportsAnsi)}") + .AddRow("[b]Legacy console?[/]", $"{YesNo(AnsiConsole.Capabilities.LegacyConsole)}") + .AddRow("[b]Buffer width[/]", $"{AnsiConsole.Console.Width}") + .AddRow("[b]Buffer height[/]", $"{AnsiConsole.Console.Height}"); AnsiConsole.Render( new Panel(grid) .SetHeader("Information")); } - private static string GetEmoji(bool value) => value - ? ":thumbs_up:" - : ":thumbs_down:"; + private static string YesNo(bool value) + { + return value ? "Yes" : "No"; + } } } diff --git a/examples/Links/Links.csproj b/examples/Links/Links.csproj index 5b35d6f..20480bb 100644 --- a/examples/Links/Links.csproj +++ b/examples/Links/Links.csproj @@ -4,6 +4,7 @@ Exe netcoreapp3.1 false + Links Demonstrates how to render links in a console. diff --git a/examples/Links/Program.cs b/examples/Links/Program.cs index 68b52ed..ee70d59 100644 --- a/examples/Links/Program.cs +++ b/examples/Links/Program.cs @@ -1,6 +1,6 @@ using Spectre.Console; -namespace Links +namespace LinkExample { public static class Program { diff --git a/examples/Panel/Panel.csproj b/examples/Panels/Panels.csproj similarity index 93% rename from examples/Panel/Panel.csproj rename to examples/Panels/Panels.csproj index 2be9dc1..125afa8 100644 --- a/examples/Panel/Panel.csproj +++ b/examples/Panels/Panels.csproj @@ -4,6 +4,7 @@ Exe netcoreapp3.1 false + Panels Demonstrates how to render items in panels. diff --git a/examples/Panel/Program.cs b/examples/Panels/Program.cs similarity index 100% rename from examples/Panel/Program.cs rename to examples/Panels/Program.cs diff --git a/examples/Table/Program.cs b/examples/Tables/Program.cs similarity index 100% rename from examples/Table/Program.cs rename to examples/Tables/Program.cs diff --git a/examples/Table/Table.csproj b/examples/Tables/Tables.csproj similarity index 93% rename from examples/Table/Table.csproj rename to examples/Tables/Tables.csproj index f61793f..3b4c13e 100644 --- a/examples/Table/Table.csproj +++ b/examples/Tables/Tables.csproj @@ -4,6 +4,7 @@ Exe netcoreapp3.1 false + Tables Demonstrates how to render tables in a console. diff --git a/src/Spectre.Console.sln b/src/Spectre.Console.sln index f7d4a58..25fe573 100644 --- a/src/Spectre.Console.sln +++ b/src/Spectre.Console.sln @@ -17,11 +17,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Examples", "Examples", "{F0575243-121F-4DEE-9F6B-246E26DC0844}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Table", "..\examples\Table\Table.csproj", "{94ECCBA8-7EBF-4B53-8379-52EB2327417E}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tables", "..\examples\Tables\Tables.csproj", "{94ECCBA8-7EBF-4B53-8379-52EB2327417E}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Panel", "..\examples\Panel\Panel.csproj", "{BFF37228-B376-4ADD-9657-4E501F929713}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Panels", "..\examples\Panels\Panels.csproj", "{BFF37228-B376-4ADD-9657-4E501F929713}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Grid", "..\examples\Grid\Grid.csproj", "{C7FF6FDB-FB59-4517-8669-521C96AB7323}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Grids", "..\examples\Grids\Grids.csproj", "{C7FF6FDB-FB59-4517-8669-521C96AB7323}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Colors", "..\examples\Colors\Colors.csproj", "{1F51C55C-BA4C-4856-9001-0F7924FFB179}" EndProject @@ -33,7 +33,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Borders", "..\examples\Bord EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Links", "..\examples\Links\Links.csproj", "{6AF8C93B-AA41-4F44-8B1B-B8D166576174}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Emojis", "..\examples\Emojis\Emojis.csproj", "{1EABB956-957F-4C1A-8AC0-FD19C8F3C2F2}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Emojis", "..\examples\Emojis\Emojis.csproj", "{1EABB956-957F-4C1A-8AC0-FD19C8F3C2F2}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution