public void Exec(SubCommandRunningContext context) { var builder = new XRefArchiveBuilder(); if (Uri.TryCreate(_options.Uri, UriKind.RelativeOrAbsolute, out Uri uri)) { builder.DownloadAsync(uri, _options.ArchiveFile).Wait(); } else { Logger.LogError($"Invalid uri: {_options.Uri}"); } }
public async Task TestDownload() { const string ZipFile = "test.zip"; var builder = new XRefArchiveBuilder(); Assert.True(await builder.DownloadAsync(new Uri("http://dotnet.github.io/docfx/xrefmap.yml"), ZipFile)); using (var xar = XRefArchive.Open(ZipFile, XRefArchiveMode.Read)) { var map = xar.GetMajor(); Assert.True(map.HrefUpdated); Assert.True(map.Sorted); Assert.NotNull(map.References); Assert.Null(map.Redirections); } File.Delete(ZipFile); }
public void Exec(SubCommandRunningContext context) { if (string.IsNullOrWhiteSpace(_options.ArchiveFile)) { Logger.LogError("Please provide output file."); return; } var builder = new XRefArchiveBuilder(); if (Uri.TryCreate(_options.Uri, UriKind.RelativeOrAbsolute, out Uri uri)) { builder.DownloadAsync(uri, _options.ArchiveFile).Wait(); } else { Logger.LogError($"Invalid uri: {_options.Uri}"); } }