public static int Download(RemoteSourceDownloadOptions downloadOpts, TextWriter output, TextWriter error) { if (downloadOpts.Config) { RemoteSourceWorker.DownloadConfig(downloadOpts, output, error); } else { RemoteSourceWorker.DownloadContent(downloadOpts, output, error); } return(0); }
public static void DownloadConfig(RemoteSourceDownloadOptions options, TextWriter output, TextWriter error) { try { output.WriteCommandHeader($"Downloading template source config file from environment {options.Env.ToString()} ({options.StorageAccount})"); output.WriteLine(); var result = RemoteSource.DownloadCdnElement(Environments.CdnUrls[options.Env], "config.json", options.Destination); output.WriteCommandText($"Successfully downloaded '{result}'"); output.WriteLine(); } catch (Exception ex) { error.WriteException(ex, $"Unable to download the config file from the specified environment."); } }
public static void DownloadContent(RemoteSourceDownloadOptions options, TextWriter output, TextWriter error) { try { var shortLanguage = ProgrammingLanguages.GetShortProgrammingLanguage(options.Language); output.WriteCommandHeader($"Downloading templates content from environment {options.Env.ToString()} ({options.StorageAccount})"); TemplatesSourceConfig config = GetConfigFromCdn(options.Env); TemplatesPackageInfo package = null; if (options.Version != null) { package = ResolvePackageForVersion(config, options.Version, options.Platform, shortLanguage, output); } else { package = config.Latest; } if (package != null) { Fs.EnsureFolderExists(options.Destination); var result = RemoteSource.DownloadCdnElement(Environments.CdnUrls[options.Env], package.Name, options.Destination); output.WriteLine(); output.WriteCommandText($"Successfully downloaded '{result}'"); output.WriteLine(); } else { output.WriteLine(); output.WriteCommandText($"Package not found for the version '{options.Version}', platform '{options.Platform}' and laguage '{options.Language}'"); output.WriteLine(); } } catch (Exception ex) { error.WriteException(ex, $"Unable to download the file content from the specified environment."); } }