private async Task OnExecute(IConsole console) { if (!All && Version == default && Regex == default) { console.WriteErrorAndExit("You should pass a runtime --version, --regex or the --all option to remove runtime/s"); } var installed = await DotnetPackages.Get(PackageType.Runtime, console); if (!All && Regex == default) { var target = installed.FirstOrDefault(i => i.version == Version); if (target.version == default) { console.WriteErrorAndExit($"Runtime version {Version} was not found"); } removeRuntime(target.version, target.props, console); return; } if (Regex != default) { console.WriteLine($"Removing runtimes using regex: {Regex}"); DotnetRuntime.RemoveWithRegex(Regex, console); return; } foreach (var runtime in installed) { removeRuntime(runtime.version, runtime.props, console); } }
private void removeRuntime(string identifier, string version, IConsole console, string regex = default) { console.WriteLine($"Looking for runtime {identifier}"); DotnetRuntime.Remove(identifier, version, console); }