public static void ProcessCUI(string input, Reflector refl) { if (input == "stop") { StartStopManager.Exit(refl); } else if (input == "exit") { StartStopManager.Exit(refl); } else if (input == "info") { Print("by chrissx, created in December of 2017", refl); } else if (input == "moving") { Print("Currently moving files:", refl, ConsoleColor.Gray); foreach (string s in refl.movingFiles) { Print(s, refl); } } else if (input == "help") { Print("Currently available commands: stop, exit, info, moving, help, files, update, config-regen", refl); } else if (input == "files") { Print("Currently moving files:", refl, ConsoleColor.Gray); foreach (string s in refl.movingFiles) { Print(s, refl); } } else if (input == "update") { refl.updateManager.Update(null, false); } else if (input == "config-regen") { Print("Regenerating config.", refl, ConsoleColor.Yellow); refl.stop = true; refl.run = false; refl.blockthreads = true; Print("Joining threads in order to stop for config.", refl, ConsoleColor.Gray); refl.threadManager.Destruct(); Print("Stopping for config regen.", refl, ConsoleColor.DarkRed); File.Delete(P.config_file); File.WriteAllText(P.config_file, Resources.DEF_CONFIG); refl.logger.SaveLog(refl.config.log_path, false); Environment.Exit(0); } else { Print("Cannot recognize that command. Enter \"help\" for help.", refl, ConsoleColor.DarkRed); } }
static void Main(string[] args) { refl = new Reflector(); Util.Print("::AutoMover by chrissx (version " + VersionStr + ")::", refl, ConsoleColor.Cyan); if (!File.Exists(P.config_file)) { File.WriteAllText(P.config_file, Resources.DEF_CONFIG); Util.Print("CREATED CONFIG FILE, PLEASE EDIT IT, THE LOCATION IS " + P.config_file, refl, ConsoleColor.Red); Util.Print("PRESS ENTER TO CLOSE THIS", refl, ConsoleColor.Red); Console.Read(); Environment.Exit(0); } refl.config = new ConfigParser(File.ReadAllLines(P.config_file), refl).Parse(); if (refl.config.beta) { Util.Print("[BETA " + BetaVersionStr + "]", refl, ConsoleColor.Cyan); } DirFileChecker.StartCheck(refl); Thread.Sleep(50); InitDrives(Util.GetDrives()); refl.threadManager.StartThread(() => { try { while (refl.run && !refl.stop) { Thread.Sleep(1000); CheckDrives(Util.GetDrives()); ListChecker.CheckMovingDrives(refl); ListChecker.CheckMovedDrives(Util.GetDrives(), refl); if (refl.i >= 100) { Console.Clear(); refl.logger.SaveLog(refl.config.log_path, true); refl.i = 0; } if (Process.GetCurrentProcess().WorkingSet64 > refl.config.maxRam) { StartStopManager.Restart(refl); } } } catch (Exception e) { if (refl.config.debug) { Util.Print(Util.ExceptionString(e), refl); } } }, "AutoMover-BackgroundChecker"); Thread.Sleep(50); refl.updateManager.CheckUpdates(true); while (refl.run && !refl.stop) { string inpu = Console.ReadLine(); refl.logger.AddLog("[" + Util.CurrentTime() + "][IN] " + inpu); string[] splitted = inpu.Split(' '); string input = splitted[0]; Util.ProcessCUI(input, refl); } }