public static void UpdateMod( [Required] [Aliases("user,u")] string username, [Required] [Aliases("pass,p")] string password, [Required] [Aliases("mod,m")] long modId, [Required] [Aliases("ver,v")] string version, [Required] [Aliases("ksp,k")] string ksp_version, [Aliases("log,l")] string changelog, [DefaultValue(false)] [Aliases("notify,n")] bool notifyFollowers, [Required] [Aliases("file,f")] string filePath ) { ModVersion ver; if (changelog != string.Empty) { ver = new ModVersion(version, ksp_version, changelog); } else { ver = new ModVersion(version, ksp_version); } var loginDict = KerbalStuff.Login(username, password); if (loginDict == null) { WriteErrorLine("Could not complete login attempt: {0}", KerbalStuff.currentResponse.StatusDescription); } else if (loginDict.ContainsKey("error") && loginDict["error"].ToString().ToLower() == "true") { WriteErrorLine("Login failed: {0}", loginDict["reason"]); } else { var updateDict = KerbalStuff.Update(modId, ver, notifyFollowers, Path.GetFileName(filePath), filePath); if (updateDict == null) { WriteErrorLine("Could not complete creation attempt: {0}", KerbalStuff.currentResponse.StatusDescription); } else if (updateDict.ContainsKey("error") && updateDict["error"].ToString().ToLower() == "true") { WriteErrorLine("Creation failed: {0}", updateDict["reason"]); } else { WriteOutLine("Mod #{0}! You can view the update at {1}", updateDict["id"], string.Concat(KerbalStuff.RootUri, updateDict["url"]) ); } } }
public static void CreateMod( [Required] [Aliases("user,u")] string username, [Required] [Aliases("pass,p")] string password, [Required] [Aliases("n")] string name, [Required] [Aliases("desc,d")] string short_description, [Required] [Aliases("ver,v")] string version, [Required] [Aliases("ksp,k")] string ksp_version, [Required] [Aliases("lic,l")] string license, [Required] [Aliases("file,f")] string filePath ) { Mod mod = new Mod(name, short_description, version, ksp_version, license); var loginDict = KerbalStuff.Login(username, password); if (loginDict == null) { WriteErrorLine("Could not complete login attempt: {0}", KerbalStuff.currentResponse.StatusDescription); } else if (loginDict.ContainsKey("error") && loginDict["error"].ToString().ToLower() == "true") { WriteErrorLine("Login failed: {0}", loginDict["reason"]); } else { var createDict = KerbalStuff.Create(mod, Path.GetFileName(filePath), filePath); if (createDict == null) { WriteErrorLine("Could not complete creation attempt: {0}", KerbalStuff.currentResponse.StatusDescription); } else if (createDict.ContainsKey("error") && createDict["error"].ToString().ToLower() == "true") { WriteErrorLine("Creation failed: {0}", createDict["reason"]); } else { WriteOutLine("New mod '{0}' created with id #{2}! You can view and publish the mod at {1}", createDict["name"], string.Concat(KerbalStuff.RootUri, createDict["url"]), createDict["id"] ); } } }