From 343144af847ecebf35be94a24bf3d57826667b5a Mon Sep 17 00:00:00 2001 From: "Jeremy D. Miller" Date: Mon, 23 Sep 2024 15:37:25 -0500 Subject: [PATCH] Fixed up Spectre usage. Closes GH-94 --- src/EnvironmentCheckDemonstrator/Describers.cs | 2 +- src/MvcApp/Describers.cs | 2 +- src/Oakton/CommandExecutor.cs | 4 ++-- src/Oakton/CommandFactory.cs | 6 +++--- src/Oakton/Commands/CheckEnvironmentCommand.cs | 4 ++-- src/Tests/Descriptions/DescribeCommandTests.cs | 2 +- src/quickstart/Program.cs | 6 +++--- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/EnvironmentCheckDemonstrator/Describers.cs b/src/EnvironmentCheckDemonstrator/Describers.cs index 74a75866..09312c50 100644 --- a/src/EnvironmentCheckDemonstrator/Describers.cs +++ b/src/EnvironmentCheckDemonstrator/Describers.cs @@ -28,7 +28,7 @@ public Task Write(TextWriter writer) public Task WriteToConsole() { - AnsiConsole.Write("[darkblue]Second part writing in blue[/]"); + AnsiConsole.MarkupLine("[darkblue]Second part writing in blue[/]"); return Task.CompletedTask; } } diff --git a/src/MvcApp/Describers.cs b/src/MvcApp/Describers.cs index 5871050e..ee19fc17 100644 --- a/src/MvcApp/Describers.cs +++ b/src/MvcApp/Describers.cs @@ -28,7 +28,7 @@ public Task Write(TextWriter writer) public Task WriteToConsole() { - AnsiConsole.Write("[darkblue]Second part writing in blue[/]"); + AnsiConsole.MarkupLine("[darkblue]Second part writing in blue[/]"); return Task.CompletedTask; } } diff --git a/src/Oakton/CommandExecutor.cs b/src/Oakton/CommandExecutor.cs index b7532727..b60fddf8 100644 --- a/src/Oakton/CommandExecutor.cs +++ b/src/Oakton/CommandExecutor.cs @@ -41,14 +41,14 @@ private static async Task execute(CommandRun run) } catch (CommandFailureException e) { - AnsiConsole.Write("[red]ERROR:[/]"); + AnsiConsole.MarkupLine("[red]ERROR:[/]"); AnsiConsole.WriteException(e); return 1; } catch (Exception ex) { - AnsiConsole.Write("[red]ERROR:[/]"); + AnsiConsole.MarkupLine("[red]ERROR:[/]"); AnsiConsole.WriteException(ex); return 1; diff --git a/src/Oakton/CommandFactory.cs b/src/Oakton/CommandFactory.cs index 5dffd767..735c1474 100644 --- a/src/Oakton/CommandFactory.cs +++ b/src/Oakton/CommandFactory.cs @@ -220,18 +220,18 @@ private CommandRun buildRun(Queue queue, string commandName) } catch (InvalidUsageException e) { - AnsiConsole.Write("[red]Invalid usage[/]"); + AnsiConsole.MarkupLine("[red]Invalid usage[/]"); if (e.Message.IsNotEmpty()) { - AnsiConsole.Write($"[yellow]{e.Message.EscapeMarkup()}[/]"); + AnsiConsole.MarkupLine($"[yellow]{e.Message.EscapeMarkup()}[/]"); } Console.WriteLine(); } catch (Exception e) { - AnsiConsole.Write("[red]Error parsing input[/]"); + AnsiConsole.MarkupLine("[red]Error parsing input[/]"); AnsiConsole.WriteException(e); Console.WriteLine(); diff --git a/src/Oakton/Commands/CheckEnvironmentCommand.cs b/src/Oakton/Commands/CheckEnvironmentCommand.cs index 567410e0..d8976f07 100644 --- a/src/Oakton/Commands/CheckEnvironmentCommand.cs +++ b/src/Oakton/Commands/CheckEnvironmentCommand.cs @@ -33,11 +33,11 @@ public override async Task Execute(CheckEnvironmentInput input) if (results.Failures.Any()) { - AnsiConsole.Write("[red]Some environment checks failed![/]"); + AnsiConsole.MarkupLine("[red]Some environment checks failed![/]"); return false; } - AnsiConsole.Write("[green]All environment checks are good![/]"); + AnsiConsole.MarkupLine("[green]All environment checks are good![/]"); return true; } } \ No newline at end of file diff --git a/src/Tests/Descriptions/DescribeCommandTests.cs b/src/Tests/Descriptions/DescribeCommandTests.cs index d9628051..4c54beb6 100644 --- a/src/Tests/Descriptions/DescribeCommandTests.cs +++ b/src/Tests/Descriptions/DescribeCommandTests.cs @@ -144,7 +144,7 @@ public Task Write(TextWriter writer) public Task WriteToConsole() { - AnsiConsole.Write("[darkblue]Second part writing in blue[/]"); + AnsiConsole.MarkupLine("[darkblue]Second part writing in blue[/]"); return Task.CompletedTask; } } diff --git a/src/quickstart/Program.cs b/src/quickstart/Program.cs index 60775891..56dab4e5 100755 --- a/src/quickstart/Program.cs +++ b/src/quickstart/Program.cs @@ -50,7 +50,7 @@ public override bool Execute(NameInput input) text = input.TitleFlag + " " + text; } - AnsiConsole.Write($"[{input.Color}]{text}[/]"); + AnsiConsole.MarkupLine($"[{input.Color}]{text}[/]"); // Just telling the OS that the command // finished up okay @@ -100,10 +100,10 @@ public class DoNameThingsCommand : OaktonAsyncCommand { public override async Task Execute(NameInput input) { - AnsiConsole.Write($"[{input.Color}]Starting...[/]"); + AnsiConsole.MarkupLine($"[{input.Color}]Starting...[/]"); await Task.Delay(TimeSpan.FromSeconds(3)); - AnsiConsole.Write($"[{input.Color}]Done! Hello {input.Name}[/]"); + AnsiConsole.MarkupLine($"[{input.Color}]Done! Hello {input.Name}[/]"); return true; } }