//Design standard
 public static void UpdatePackages(Validator val, PackageOverview overview)
 {
     //If we update all with wildcard *. This method doesn't require a list of previous packages.
     if (val.updateAll)
     {
         foreach (Package i in overview.packages)
         {
             if (PackageUtil.DoesPackageExist(i))
             {
                 Update(i, val, overview).Wait();
             }
         }
     }
     //If we list packages
     else
     {
         foreach (string i in val.packageNames)
         {
             if (overview.GetPackageWithName(i) != null)
             {
                 Update(overview.GetPackageWithName(i), val, overview).Wait();
             }
             else
             {
                 Console.WriteLine(("WARNING: No package with name " + i + ".").Pastel("ffff00"));
             }
         }
     }
 }
 //Design standard
 public static void RemovePackages(Validator val, PackageOverview overview)
 {
     if (val.removeAll)
     {
         foreach (Package i in overview.packages)
         {
             //It's redundant, but prevents spamming errors.
             if (PackageUtil.DoesPackageExist(i))
             {
                 Remove(i, val, overview);
             }
         }
     }
     else
     {
         foreach (string i in val.packageNames)
         {
             Package current = overview.GetPackageWithName(i);
             if (current != null)
             {
                 Remove(current, val, overview);
             }
             else
             {
                 Console.WriteLine(("WARNING: No package with name " + i + ".").Pastel("ffff00"));
             }
         }
     }
 }
 //This is the way commands should be set up. 1st func loops over packages and triggers 2nd for each. 1st is public, 2nd is private.
 public static void InstallPackages(Validator val, PackageOverview overview)
 {
     foreach (string i in val.packageNames)
     {
         //If it exists, install
         Package info = overview.GetPackageWithName(i);
         if (info != null)
         {
             GetFile(info, overview, val).Wait();
         }
         else
         {
             Console.WriteLine(("ERROR: No package with name " + i).Pastel("ff0000"));
         }
     }
 }
        private static async Task GetFile(Package package, PackageOverview overview, Validator val)
        {
            Console.WriteLine("Downloading " + package.name);
            //Download dependencies first
            foreach (string i in package.dependencies)
            {
                await GetFile(overview.GetPackageWithName(i), overview, val);
            }
            //Check if any incompatible package are installed
            bool incompat = false;

            foreach (string i in package.incompatibilities)
            {
                if (PackageUtil.DoesPackageExist(overview.GetPackageWithName(i)))
                {
                    bool res = Dialog.YNDialog(("WARNING: " + package.name + " is incompatiable with " + i + ". Would you like to remove the other package (Yes/No)? ").Pastel("ffff00"));
                    if (res)
                    {
                        Validator newVal = ClassCopy.DeepCopy(val);
                        newVal.packageNames = new List <string> {
                            i
                        };
                        Remover.RemovePackages(newVal, overview);
                    }
                    else
                    {
                        incompat = true;
                    }
                }
            }
            if (!incompat)
            {
                //Check if file already exists
                if (!PackageUtil.DoesPackageExist(package))
                {
                    using (WebClient client = new WebClient())
                    {
                        //Setup loading bar
                        client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(LoadingBar.DownloadProgressCallback);
                        //Download file to directory after checking if the folders existba
                        if (PackageUtil.DoesDirectoryExist(package))
                        {
                            await client.DownloadFileTaskAsync(package.downloadLink, "../sm_plugins/" + package.downloadLocation);

                            Console.Write("\n\r");
                        }
                        else
                        {
                            if (val.createDir)
                            {
                                Directory.CreateDirectory(Path.GetDirectoryName("../sm_plugins/" + package.downloadLocation));
                                await client.DownloadFileTaskAsync(package.downloadLink, "../sm_plugins/" + package.downloadLocation);

                                Console.Write("\n\r");
                            }
                            else
                            {
                                Console.WriteLine("ERROR: The folder to install to does not exist. Did you unzip all the app files into a folder at the same level as sm_plugins?".Pastel("ff0000"));
                            }
                        }
                    }
                }
                else
                {
                    Console.WriteLine(("WARNING: Plugin " + package.name + " is already installed, skipping.").Pastel("ffff000"));
                }
            }
        }