mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-06-18 21:08:15 +08:00
Add Spectre.Cli to Spectre.Console
* Renames Spectre.Cli to Spectre.Console.Cli. * Now uses Verify with Spectre.Console.Cli tests. * Removes some duplicate definitions. Closes #168
This commit is contained in:

committed by
Patrik Svensson

parent
0bbf9b81a9
commit
0ae419326d
29
examples/Cli/Demo/Utilities/SettingsDumper.cs
Normal file
29
examples/Cli/Demo/Utilities/SettingsDumper.cs
Normal file
@ -0,0 +1,29 @@
|
||||
using Spectre.Console;
|
||||
using Spectre.Console.Cli;
|
||||
|
||||
namespace Demo.Utilities
|
||||
{
|
||||
public static class SettingsDumper
|
||||
{
|
||||
public static void Dump(CommandSettings settings)
|
||||
{
|
||||
var table = new Table().RoundedBorder();
|
||||
table.AddColumn("[grey]Name[/]");
|
||||
table.AddColumn("[grey]Value[/]");
|
||||
|
||||
var properties = settings.GetType().GetProperties();
|
||||
foreach (var property in properties)
|
||||
{
|
||||
var value = property.GetValue(settings)
|
||||
?.ToString()
|
||||
?.Replace("[", "[[");
|
||||
|
||||
table.AddRow(
|
||||
property.Name,
|
||||
value ?? "[grey]null[/]");
|
||||
}
|
||||
|
||||
AnsiConsole.Render(table);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user