/// <summary> /// Install the version specified by code or name, /// if both are null latest version is installed /// </summary> /// <param name="code">Target version code to be installed.</param> /// <param name="name">Target version name to be installed.</param> public void Install(int code, string name) { Version version = null; if (code > 0) { version = _project.GetVersion(code); } else if (!string.IsNullOrEmpty(name)) { version = _project.GetVersion(name); } else { version = _project.GetLatestVersion(); } if (version == null) { Console.WriteLine("Version could not be found."); return; } Console.WriteLine("Starting Download..."); if (!DriveUtils.DownloadFile(FilePath.TempZipFile, version.FileId)) { Console.WriteLine("Downloding updated failed."); return; } UnzipFiles(); var configJson = new ConfigJson(_project.SoftwareName, version.VersionCode); configJson.SaveJson(); Console.WriteLine($"Updated to version code {version.VersionName}"); }
/// <summary> /// Delete a version with versionCode or versionName /// </summary> /// <param name="versionCode">Version to delete with versionCode</param> /// <param name="versionName">Version to delete with versionName</param> public void Drop(int versionCode, string versionName) { Version version = null; if (versionCode > 0) { version = _project.GetVersion(versionCode); } else if (versionName != null) { version = _project.GetVersion(versionName); } if (version == null) { Console.WriteLine("Version not found"); return; } _project.DeleteVersionFromDrive(version); Console.WriteLine($"{version} deleted from drive."); }