Exemple #1
0
        public static void Auto(string input) //? Add/Remove modules from Autostart
        {
            ConfigurationFile module = new ConfigurationFile(Path.Combine(AppContext.BaseDirectory, "modules.config"));

            if (input.Split(' ').Length < 2 || input.Contains("list")) // List all enabled/disabled auto Module
            {
                foreach (Setting s in module.GetAll())
                {
                    Shell.WriteLine(s.Value == "true" ? ConsoleColor.Green : ConsoleColor.Red, s.Key);
                }
            }

            foreach (string str in input.Split(' ').SubArray(1))
            {
                string key = module.GetAll().Where(x => x.Key.Equals(str, StringComparison.OrdinalIgnoreCase)).Select(x => x.Key).FirstOrDefault();

                if (key == null)
                {
                    Shell.WriteLineError("The module " + str + " don't exist.");
                    continue;
                }

                string value = module[key].Value;

                if (value == "false")
                {
                    module.Set(key, "true");
                    module.Save();
                    Shell.WriteLine(ConsoleColor.Cyan, "Module " + key + " added to Autostart");
                }
                else if (value == "true")
                {
                    module.Set(key, "false");
                    module.Save();
                    Shell.WriteLine(ConsoleColor.Cyan, "Module " + key + " removed from Autostart");
                }
            }
        }