public static int HandleCommandLine(string[] args, string[] options) { var terms = string.Join(" ", args); var search = KerbalStuff.Search(terms); var results = search.Where(r => r.Name.ToUpper() == terms.ToUpper() || r.Author.ToUpper() + "/" + r.Name.ToUpper() == terms.ToUpper()); if (!results.Any()) { results = search; } if (results.Count() > 1) { Console.WriteLine("Error: \"{0}\" is ambiguous between:"); foreach (var m in results) { Console.WriteLine("{0}/{1} [{2}]", m.Author, m.Name, m.Downloads); } return(1); } var mod = results.Single(); Console.WriteLine("{0}/{1}", mod.Author, mod.Name); Console.WriteLine("Name: {0}", mod.Name); Console.WriteLine("Author: {0}", mod.Author); Console.WriteLine("URL: {1}/{0}", mod.Id, Settings.KS_MOD); Console.WriteLine("Version: {0}", mod.Versions[0].FriendlyVersion); Console.WriteLine("Downloads: {0}", mod.Downloads); Console.WriteLine("Followers: {0}", mod.Followers); Console.WriteLine("Short Description: \n\t{0}", mod.ShortDescription); return(0); }
public static int HandleCommandLine(string[] args, string[] options) { bool all = false; foreach (var option in options) { switch (option) { case "--all": all = true; break; default: Console.WriteLine("Invalid option: " + option); return(1); } } var results = KerbalStuff.Search(string.Join(" ", args)); if (!all) { // TODO: Filter out unsupported versions } foreach (var result in results) { Console.WriteLine("{0}/{1} [{2}]", result.Author, result.Name, result.Downloads); Console.WriteLine("\t" + Truncate(result.ShortDescription, Console.WindowWidth - 8)); } return(0); }
public static int HandleCommandLine(string[] args, string[] options) { var terms = string.Join(" ", args); var search = KerbalStuff.Search(terms); var results = search.Where(r => r.Name.ToUpper() == terms.ToUpper() || r.Author.ToUpper() + "/" + r.Name.ToUpper() == terms.ToUpper()); if (!results.Any()) { results = search; } if (results.Count() > 1) { Console.WriteLine("Error: \"{0}\" is ambiguous between:"); foreach (var m in results) { Console.WriteLine("{0}/{1} [{2}]", m.Author, m.Name, m.Downloads); } return(1); } var mod = results.Single(); using (WebClient client = new WebClient()) { string sOutput = String.Format("{0}-{1}.zip", mod.Name, mod.Versions.First().FriendlyVersion); Console.WriteLine("Downloading \"{0}\" to working directory...", sOutput); Console.WriteLine("\tPlease wait ..."); client.DownloadFile(Settings.KS_ROOT + mod.Versions.First().DownloadPaths, sOutput); Console.WriteLine("\nDownload completed Successfully."); } return(0); }
public static int HandleCommandLine(string[] args, string[] options) { var terms = string.Join(" ", args); var search = KerbalStuff.Search(terms); var results = search.Where(r => r.Name.ToUpper() == terms.ToUpper() || r.Author.ToUpper() + "/" + r.Name.ToUpper() == terms.ToUpper()); if (!results.Any()) { results = search; } if (results.Count() > 1) { Console.WriteLine("Error: \"{0}\" is ambiguous between:"); foreach (var m in results) { Console.WriteLine("{0}/{1} [{2}]", m.Author, m.Name, m.Downloads); } return(1); } var mod = results.Single(); foreach (var version in mod.Versions) { Console.WriteLine("== Version {0} (for KSP {1})", version.FriendlyVersion, version.KSPVersion); if (string.IsNullOrEmpty(version.Changelog)) { Console.WriteLine("The first version of {0}", mod.Name); } else { Console.WriteLine(version.Changelog); } Console.WriteLine(); } return(0); }