static void Main(string[] args) { string outputPath = "src/update.json"; var update = new UpdateResponse { Version = VersionUtils.CurrentVersion }; var optionSet = new OptionSet { { "h|?|help", s => PrintUsageAndExit() }, { "workspace=", s => Environment.CurrentDirectory = s }, { "r=|mirror=", s => update.Mirrors.Add(s) }, { "w|windows", s => _curPlatform = update.Platforms.Windows }, { "m|mac", s => _curPlatform = update.Platforms.Mac }, { "l|linux", s => _curPlatform = update.Platforms.Linux }, { "s=|setup=", s => _curPlatform.Packages.Setup = CreatePackage(s) }, { "x=|sfx=", s => _curPlatform.Packages.Sfx = CreatePackage(s) }, { "7=|7z=|7zip=|sevenZip=", s => _curPlatform.Packages.SevenZip = CreatePackage(s) }, { "z=|zip=", s => _curPlatform.Packages.Zip = CreatePackage(s) }, { "o=|output=", s => outputPath = s }, }; var extra = optionSet.Parse(args); if (extra.Any()) { Logger.WarnFormat("Warning: Unknown arguments passed; ignoring: [ \"{0}\" ]", string.Join("\", \"", extra)); } var json = JsonConvert.SerializeObject(update, Formatting.Indented); File.WriteAllText(outputPath, json); }
private static Platform GetPlatform(UpdateResponse response) { var platforms = response.Platforms; var osType = SystemInfo.Instance.OS.Type; if (OSType.Mac == osType) return platforms.Mac; if (OSType.Linux == osType) return platforms.Linux; return platforms.Windows; }
private Update FromResponse(UpdateResponse response) { var mirror = response.Mirrors.First(); var platform = GetPlatform(response); var package = GetPackage(platform); // No package available for the user's OS if (package == null) { return null; } var version = response.Version; var filename = package.FileName; var uri = mirror + filename; return new Update(version, filename, uri, package.SHA1, package.Size); }
public static Update FromResponse([NotNull] UpdateResponse response, bool isPortable) { var version = response.Version; return(new Update(version)); }