diff --git a/UpToolCLI/Program.cs b/UpToolCLI/Program.cs index 7d3ee2a..b8e7ccc 100644 --- a/UpToolCLI/Program.cs +++ b/UpToolCLI/Program.cs @@ -16,11 +16,11 @@ namespace UpToolCLI MutexLock.Lock(); try { - XmlTool.FixXml(); ExternalFunctionalityManager.Init(Functions); + XmlTool.FixXml(); RootCommand rootCommand = new RootCommand(); rootCommand.AddGlobalOption(new Option("--basic")); - UtLibFunctions.Basic = args.Contains("--basic"); + UtLibFunctions.Basic = args.Length > 0 && args[0] == "--basic"; PackageManagement.RegisterCommands(rootCommand); CacheManagement.RegisterCommands(rootCommand); diff --git a/UpToolCLI/ReposManagement.cs b/UpToolCLI/ReposManagement.cs index 029d92b..dbaf550 100644 --- a/UpToolCLI/ReposManagement.cs +++ b/UpToolCLI/ReposManagement.cs @@ -76,19 +76,14 @@ namespace UpToolCLI }, u => u.Element("Name").Value, u => u.Element("Link").Value)); - Console.WriteLine("Are you sure you want to delete them all? (y/n)"); - ConsoleKey k; - do - k = Console.ReadKey().Key; - while (k != ConsoleKey.Y && k != ConsoleKey.N); - if (k == ConsoleKey.N || k != ConsoleKey.Y) + if (!Program.Functions.YesNoDialog("Are you sure you want to delete them all?", false)) return; break; } - for (int i = 0; i < sRepos.Length; i++) + foreach (XElement t in sRepos) { - Console.WriteLine($"Removing {sRepos[i].Element("Name").Value}"); - sRepos[i].Remove(); + Console.WriteLine($"Removing {t.Element("Name").Value}"); + t.Remove(); } doc.Save(PathTool.InfoXml); Console.WriteLine("Removed repo. Remember to update the cache using \"uptool update\""); diff --git a/UpToolCLI/UTLibFunctions.cs b/UpToolCLI/UTLibFunctions.cs index 98cfc47..6729af3 100644 --- a/UpToolCLI/UTLibFunctions.cs +++ b/UpToolCLI/UTLibFunctions.cs @@ -54,8 +54,8 @@ namespace UpToolCLI if (Basic) { Console.WriteLine(text); - Console.WriteLine("Selecting \"Yes\""); - return false; + Console.WriteLine($"Selecting: {defaultVal}"); + return defaultVal; } else { diff --git a/UpToolLib/Tool/XmlTool.cs b/UpToolLib/Tool/XmlTool.cs index b386335..2475887 100644 --- a/UpToolLib/Tool/XmlTool.cs +++ b/UpToolLib/Tool/XmlTool.cs @@ -30,9 +30,15 @@ namespace UpToolLib.Tool if (meta.Element("Repos") == null) meta.Add(new XElement("Repos")); if (meta.Element("Repos").Elements("Repo").Count() == 0) - meta.Element("Repos").Add(new XElement("Repo", new XElement("Name", "UpTool2 official Repo"), - new XElement("Link", - "https://gitlab.com/JFronny/UpTool2/snippets/1988600/raw"))); + { + if (ExternalFunctionalityManager.Instance.YesNoDialog( + "No active repository was detected. Add the default repo?", false)) + { + meta.Element("Repos").Add(new XElement("Repo", new XElement("Name", "UpTool2 official Repo"), + new XElement("Link", + "https://gitlab.com/JFronny/UpTool2/snippets/1988600/raw"))); + } + } meta.Element("Repos").Elements("Repo").Select(s => s.Element("Link")) .Where(s => new[] {