Skip to content

Commit

Permalink
Fixed up Spectre usage. Closes GH-94
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremydmiller committed Sep 23, 2024
1 parent 196ac6c commit 343144a
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/EnvironmentCheckDemonstrator/Describers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/MvcApp/Describers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Oakton/CommandExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ private static async Task<int> 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;
Expand Down
6 changes: 3 additions & 3 deletions src/Oakton/CommandFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -220,18 +220,18 @@ private CommandRun buildRun(Queue<string> 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();
Expand Down
4 changes: 2 additions & 2 deletions src/Oakton/Commands/CheckEnvironmentCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ public override async Task<bool> 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;
}
}
2 changes: 1 addition & 1 deletion src/Tests/Descriptions/DescribeCommandTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/quickstart/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -100,10 +100,10 @@ public class DoNameThingsCommand : OaktonAsyncCommand<NameInput>
{
public override async Task<bool> 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;
}
}
Expand Down

0 comments on commit 343144a

Please sign in to comment.