diff --git a/src/Aspire.Cli/Commands/RunCommand.cs b/src/Aspire.Cli/Commands/RunCommand.cs index 01579c72c16..8c542a782fc 100644 --- a/src/Aspire.Cli/Commands/RunCommand.cs +++ b/src/Aspire.Cli/Commands/RunCommand.cs @@ -188,9 +188,13 @@ protected override async Task ExecuteAsync(ParseResult parseResult, Cancell _ansiConsole.Write(topPadder); - var isCodespaces = _configuration.GetValue("CODESPACES", false); + // Use the presence of CodespacesUrlWithLoginToken to detect codespaces, as this is more reliable + // than environment variables since it comes from the same backend detection logic + var isCodespaces = dashboardUrls.CodespacesUrlWithLoginToken is not null; var isRemoteContainers = _configuration.GetValue("REMOTE_CONTAINERS", false); + AppendCtrlCMessage(longestLocalizedLength); + if (isCodespaces || isRemoteContainers) { bool firstEndpoint = true; @@ -202,6 +206,13 @@ protected override async Task ExecuteAsync(ParseResult parseResult, Cancell { ProcessResourceState(resourceState, (resource, endpoint) => { + // When we are appending endpoints we need + // to remove the CTRL-C message that was appended + // previously. So we can write the endpoint. + // We will append the CTRL-C message again after + // writing the endpoint. + ClearLines(2); + var endpointsGrid = new Grid(); endpointsGrid.AddColumn(); endpointsGrid.AddColumn(); @@ -220,6 +231,8 @@ protected override async Task ExecuteAsync(ParseResult parseResult, Cancell var endpointsPadder = new Padder(endpointsGrid, new Padding(3, 0)); _ansiConsole.Write(endpointsPadder); firstEndpoint = false; + + AppendCtrlCMessage(longestLocalizedLength); }); } } @@ -278,6 +291,34 @@ protected override async Task ExecuteAsync(ParseResult parseResult, Cancell } } + private void ClearLines(int lines) + { + if (lines <= 0) + { + return; + } + + for (var i = 0; i < lines; i++) + { + _ansiConsole.Write("\u001b[1A"); + _ansiConsole.Write("\u001b[2K"); // Clear the line + } + } + + private void AppendCtrlCMessage(int longestLocalizedLength) + { + + var ctrlCGrid = new Grid(); + ctrlCGrid.AddColumn(); + ctrlCGrid.AddColumn(); + ctrlCGrid.Columns[0].Width = longestLocalizedLength + 1; + ctrlCGrid.AddRow(Text.Empty, Text.Empty); + ctrlCGrid.AddRow(new Text(string.Empty), new Markup(RunCommandStrings.PressCtrlCToStopAppHost)); + + var ctrlCPadder = new Padder(ctrlCGrid, new Padding(3, 0)); + _ansiConsole.Write(ctrlCPadder); + } + private static FileInfo GetAppHostLogFile() { var homeDirectory = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); diff --git a/src/Aspire.Cli/Resources/RunCommandStrings.resx b/src/Aspire.Cli/Resources/RunCommandStrings.resx index 1b61af4795a..465f8cc111f 100644 --- a/src/Aspire.Cli/Resources/RunCommandStrings.resx +++ b/src/Aspire.Cli/Resources/RunCommandStrings.resx @@ -143,7 +143,7 @@ Endpoints - Press [bold]Ctrl+C[/] to stop the app host and exit. + Press [bold]CTRL+C[/] to stop the apphost and exit. [bold] should not be localized diff --git a/src/Aspire.Cli/Resources/xlf/RunCommandStrings.cs.xlf b/src/Aspire.Cli/Resources/xlf/RunCommandStrings.cs.xlf index 24a9b6fec55..ce90f0854a6 100644 --- a/src/Aspire.Cli/Resources/xlf/RunCommandStrings.cs.xlf +++ b/src/Aspire.Cli/Resources/xlf/RunCommandStrings.cs.xlf @@ -33,8 +33,8 @@ - Press [bold]Ctrl+C[/] to stop the app host and exit. - Stisknutím kláves [bold]Ctrl+C[/] zastavíte hostitele aplikací a ukončíte ho. + Press [bold]CTRL+C[/] to stop the apphost and exit. + Stisknutím kláves [bold]Ctrl+C[/] zastavíte hostitele aplikací a ukončíte ho. [bold] should not be localized diff --git a/src/Aspire.Cli/Resources/xlf/RunCommandStrings.de.xlf b/src/Aspire.Cli/Resources/xlf/RunCommandStrings.de.xlf index 0a12ff25def..925d22f5a78 100644 --- a/src/Aspire.Cli/Resources/xlf/RunCommandStrings.de.xlf +++ b/src/Aspire.Cli/Resources/xlf/RunCommandStrings.de.xlf @@ -33,8 +33,8 @@ - Press [bold]Ctrl+C[/] to stop the app host and exit. - Drücken Sie [bold]STRG+C[/], um den App-Host zu beenden und zu verlassen. + Press [bold]CTRL+C[/] to stop the apphost and exit. + Drücken Sie [bold]STRG+C[/], um den App-Host zu beenden und zu verlassen. [bold] should not be localized diff --git a/src/Aspire.Cli/Resources/xlf/RunCommandStrings.es.xlf b/src/Aspire.Cli/Resources/xlf/RunCommandStrings.es.xlf index dcf748e9f6b..ff37734bc6a 100644 --- a/src/Aspire.Cli/Resources/xlf/RunCommandStrings.es.xlf +++ b/src/Aspire.Cli/Resources/xlf/RunCommandStrings.es.xlf @@ -33,8 +33,8 @@ - Press [bold]Ctrl+C[/] to stop the app host and exit. - Presione [bold]Ctrl+C[/] para detener el host de la aplicación y salir. + Press [bold]CTRL+C[/] to stop the apphost and exit. + Presione [bold]Ctrl+C[/] para detener el host de la aplicación y salir. [bold] should not be localized diff --git a/src/Aspire.Cli/Resources/xlf/RunCommandStrings.fr.xlf b/src/Aspire.Cli/Resources/xlf/RunCommandStrings.fr.xlf index e186a06c8ac..0126a31434c 100644 --- a/src/Aspire.Cli/Resources/xlf/RunCommandStrings.fr.xlf +++ b/src/Aspire.Cli/Resources/xlf/RunCommandStrings.fr.xlf @@ -33,8 +33,8 @@ - Press [bold]Ctrl+C[/] to stop the app host and exit. - Appuyez sur [bold]Ctrl+C[/] pour arrêter l'hôte de l'application et quitter. + Press [bold]CTRL+C[/] to stop the apphost and exit. + Appuyez sur [bold]Ctrl+C[/] pour arrêter l'hôte de l'application et quitter. [bold] should not be localized diff --git a/src/Aspire.Cli/Resources/xlf/RunCommandStrings.it.xlf b/src/Aspire.Cli/Resources/xlf/RunCommandStrings.it.xlf index 0573b647836..950ddfdb708 100644 --- a/src/Aspire.Cli/Resources/xlf/RunCommandStrings.it.xlf +++ b/src/Aspire.Cli/Resources/xlf/RunCommandStrings.it.xlf @@ -33,8 +33,8 @@ - Press [bold]Ctrl+C[/] to stop the app host and exit. - Premi [bold]CTRL+C[/] per arrestare l'host dell'app e uscire. + Press [bold]CTRL+C[/] to stop the apphost and exit. + Premi [bold]CTRL+C[/] per arrestare l'host dell'app e uscire. [bold] should not be localized diff --git a/src/Aspire.Cli/Resources/xlf/RunCommandStrings.ja.xlf b/src/Aspire.Cli/Resources/xlf/RunCommandStrings.ja.xlf index e6fe7b7aa4f..a2e2556542e 100644 --- a/src/Aspire.Cli/Resources/xlf/RunCommandStrings.ja.xlf +++ b/src/Aspire.Cli/Resources/xlf/RunCommandStrings.ja.xlf @@ -33,8 +33,8 @@ - Press [bold]Ctrl+C[/] to stop the app host and exit. - [bold]Ctrl+C[/] キーを押してアプリ ホスティング プロセスを停止し、終了します。 + Press [bold]CTRL+C[/] to stop the apphost and exit. + [bold]Ctrl+C[/] キーを押してアプリ ホスティング プロセスを停止し、終了します。 [bold] should not be localized diff --git a/src/Aspire.Cli/Resources/xlf/RunCommandStrings.ko.xlf b/src/Aspire.Cli/Resources/xlf/RunCommandStrings.ko.xlf index 42fe0d02dce..86d80da73ee 100644 --- a/src/Aspire.Cli/Resources/xlf/RunCommandStrings.ko.xlf +++ b/src/Aspire.Cli/Resources/xlf/RunCommandStrings.ko.xlf @@ -33,8 +33,8 @@ - Press [bold]Ctrl+C[/] to stop the app host and exit. - 앱 호스트를 중지하고 종료하려면 [bold]Ctrl+C[/]를 누르세요. + Press [bold]CTRL+C[/] to stop the apphost and exit. + 앱 호스트를 중지하고 종료하려면 [bold]Ctrl+C[/]를 누르세요. [bold] should not be localized diff --git a/src/Aspire.Cli/Resources/xlf/RunCommandStrings.pl.xlf b/src/Aspire.Cli/Resources/xlf/RunCommandStrings.pl.xlf index 20094a183a4..e15572f19c3 100644 --- a/src/Aspire.Cli/Resources/xlf/RunCommandStrings.pl.xlf +++ b/src/Aspire.Cli/Resources/xlf/RunCommandStrings.pl.xlf @@ -33,8 +33,8 @@ - Press [bold]Ctrl+C[/] to stop the app host and exit. - Naciśnij [bold]Ctrl+C[/], aby zatrzymać hosta aplikacji i zakończyć działanie. + Press [bold]CTRL+C[/] to stop the apphost and exit. + Naciśnij [bold]Ctrl+C[/], aby zatrzymać hosta aplikacji i zakończyć działanie. [bold] should not be localized diff --git a/src/Aspire.Cli/Resources/xlf/RunCommandStrings.pt-BR.xlf b/src/Aspire.Cli/Resources/xlf/RunCommandStrings.pt-BR.xlf index 1da721f151e..4af801c82a2 100644 --- a/src/Aspire.Cli/Resources/xlf/RunCommandStrings.pt-BR.xlf +++ b/src/Aspire.Cli/Resources/xlf/RunCommandStrings.pt-BR.xlf @@ -33,8 +33,8 @@ - Press [bold]Ctrl+C[/] to stop the app host and exit. - Pressione [bold]Ctrl+C[/] para interromper o host de aplicativo e sair. + Press [bold]CTRL+C[/] to stop the apphost and exit. + Pressione [bold]Ctrl+C[/] para interromper o host de aplicativo e sair. [bold] should not be localized diff --git a/src/Aspire.Cli/Resources/xlf/RunCommandStrings.ru.xlf b/src/Aspire.Cli/Resources/xlf/RunCommandStrings.ru.xlf index 624454327a5..b53b7cb9054 100644 --- a/src/Aspire.Cli/Resources/xlf/RunCommandStrings.ru.xlf +++ b/src/Aspire.Cli/Resources/xlf/RunCommandStrings.ru.xlf @@ -33,8 +33,8 @@ - Press [bold]Ctrl+C[/] to stop the app host and exit. - Нажмите [bold]Ctrl+C[/], чтобы остановить хост приложений и выйти. + Press [bold]CTRL+C[/] to stop the apphost and exit. + Нажмите [bold]Ctrl+C[/], чтобы остановить хост приложений и выйти. [bold] should not be localized diff --git a/src/Aspire.Cli/Resources/xlf/RunCommandStrings.tr.xlf b/src/Aspire.Cli/Resources/xlf/RunCommandStrings.tr.xlf index b2873a94496..6e61787fb2f 100644 --- a/src/Aspire.Cli/Resources/xlf/RunCommandStrings.tr.xlf +++ b/src/Aspire.Cli/Resources/xlf/RunCommandStrings.tr.xlf @@ -33,8 +33,8 @@ - Press [bold]Ctrl+C[/] to stop the app host and exit. - [bold]Ctrl+C[/] tuşlarına basarak uygulama ana işlemini durdurun ve çıkın. + Press [bold]CTRL+C[/] to stop the apphost and exit. + [bold]Ctrl+C[/] tuşlarına basarak uygulama ana işlemini durdurun ve çıkın. [bold] should not be localized diff --git a/src/Aspire.Cli/Resources/xlf/RunCommandStrings.zh-Hans.xlf b/src/Aspire.Cli/Resources/xlf/RunCommandStrings.zh-Hans.xlf index b3f947570f2..6c7959b2fa1 100644 --- a/src/Aspire.Cli/Resources/xlf/RunCommandStrings.zh-Hans.xlf +++ b/src/Aspire.Cli/Resources/xlf/RunCommandStrings.zh-Hans.xlf @@ -33,8 +33,8 @@ - Press [bold]Ctrl+C[/] to stop the app host and exit. - 按 [bold]Ctrl+C[/] 以停止应用主机并退出。 + Press [bold]CTRL+C[/] to stop the apphost and exit. + 按 [bold]Ctrl+C[/] 以停止应用主机并退出。 [bold] should not be localized diff --git a/src/Aspire.Cli/Resources/xlf/RunCommandStrings.zh-Hant.xlf b/src/Aspire.Cli/Resources/xlf/RunCommandStrings.zh-Hant.xlf index f7f0bd30b96..aa1369452ce 100644 --- a/src/Aspire.Cli/Resources/xlf/RunCommandStrings.zh-Hant.xlf +++ b/src/Aspire.Cli/Resources/xlf/RunCommandStrings.zh-Hant.xlf @@ -33,8 +33,8 @@ - Press [bold]Ctrl+C[/] to stop the app host and exit. - 按 [bold]Ctrl+C[/] 以停止應用程式主機並結束。 + Press [bold]CTRL+C[/] to stop the apphost and exit. + 按 [bold]Ctrl+C[/] 以停止應用程式主機並結束。 [bold] should not be localized