command-line-api
command-line-api copied to clipboard
ScreenView.Dispose crashes because the Terminal is null
In ScreenView.Dispose its calling _console.GetTerminal().ShowCursor() but the terminal is null and so crashes with a null reference exception here.
I'm trying to run the cli in a GitHub Action the same code works fine on my local machine but not in the action. The code is basically:
using var screen new ScreenView(
new ConsoleRenderer(context.Console, context.BindingContext.OutputMode()),
context.Console
)
{
}
I tried commenting out .UseAnsiTerminalWhenAvailable() on my builder but it still does the same thing. It seems like
Actually I think its this line right here: https://github.com/dotnet/command-line-api/blob/main/src/System.CommandLine.Rendering/Terminal.cs#L50
The return type for GetTerminal() should probably be changed to be ITerminal?
You can reproduce this in any shell by redirecting the output, such as:
example # ok
echo "$(example)" # crash