| | 1 | | using System.Threading; |
| | 2 | | using System.Threading.Tasks; |
| | 3 | | using Amusoft.DotnetNew.Tests.Diagnostics; |
| | 4 | | using Amusoft.DotnetNew.Tests.Scopes; |
| | 5 | |
|
| | 6 | | namespace Amusoft.DotnetNew.Tests.CLI; |
| | 7 | |
|
| | 8 | | internal static class DotnetCli |
| | 9 | | { |
| | 10 | | public static async Task<bool> InstallAsync(string path, CancellationToken cancellationToken) |
| | 11 | | { |
| 6 | 12 | | using (var scope = new LoggingScope(false)) |
| | 13 | | { |
| | 14 | | // 106 == already installed |
| 6 | 15 | | var r = await LoggedDotnetCli.RunDotnetCommandAsync($"new install \"{path}\"", cancellationToken, null, [106]); |
| 6 | 16 | | scope.ParentScope?.AddResult(new TextResult(r ? $"Install for {path} succeded" : $"Install for {path} failed - {sc |
| 6 | 17 | | return r; |
| | 18 | | } |
| 6 | 19 | | } |
| | 20 | |
|
| | 21 | | public static async Task<bool> UninstallAsync(string path, CancellationToken cancellationToken) |
| | 22 | | { |
| 6 | 23 | | using (var scope = new LoggingScope(false)) |
| | 24 | | { |
| 6 | 25 | | var r = await LoggedDotnetCli.RunDotnetCommandAsync($"new uninstall \"{path}\"", cancellationToken, null, []); |
| 6 | 26 | | scope.ParentScope?.AddResult(new TextResult(r ? $"Uninstall for {path} succeded" : $"Uninstall for {path} failed - |
| 6 | 27 | | return r; |
| | 28 | | } |
| 6 | 29 | | } |
| | 30 | | } |