Example #1
0
        public static async Task SetupWizard()
        {
            Say(":) Welcome!");
            Say("   This is the pmcenter setup wizard.");
            Say("   App version: " + Vars.AppVer.ToString());
            Say("   Here to guide you through some *important* configurations of pmcenter.");
            SIn("=> Continue? [y/N]: ");
            if (Console.ReadLine().ToLower() != "y")
            {
                Environment.Exit(0);
            }

            Say("");
            await SetAPIKey();

            Say("");
            SetUID();
            Say("");
            SetNotifPrefs();
            Say("");
            SetAutoBanPrefs();


            // finalization
            Say("");
            Say(">> Complete!");
            Say("   All major configurations have been set!");
            Say("");
            SIn("=> Save configurations? [Y/n]: ");
            string Choice = Console.ReadLine();

            if (Choice.ToLower() != "n")
            {
                if (File.Exists(Vars.ConfFile))
                {
                    Say("Warning: pmcenter.json already exists.");
                    SIn("..       Moving the existing one to pmcenter.json.bak...");
                    File.Move(Vars.ConfFile, Vars.ConfFile + ".bak");
                    Say(" Done!");
                }
                SIn("Saving configurations to " + Vars.ConfFile + "...");
                Vars.CurrentConf = NewConf;
                await Conf.SaveConf();

                Say(" Done!");
                if (File.Exists(Vars.LangFile))
                {
                    Say("Warning: pmcenter_locale.json already exists.");
                    SIn("..       Moving the existing one to pmcenter_locale.json.bak...");
                    File.Move(Vars.LangFile, Vars.LangFile + ".bak");
                    Say(" Done!");
                }
                SIn("Saving language file to " + Vars.LangFile + "...");
                Vars.CurrentLang = new Lang.Language();
                await Lang.SaveLang();

                Say(" Done!");

                Say(">> Setup complete!");
                Say("   Thanks for using pmcenter!");
                Say("   Check out pmcenter's GitHub repository at:");
                Say("     https://github.com/Elepover/pmcenter");
                Say("   Program will now exit.");
                Say("   You can start it right away by typing this command:");
                Say("     dotnet pmcenter.dll");
                Say("   To run setup wizard again:");
                Say("     dotnet pmcenter.dll --setup");
            }
            else
            {
                Say("OK. Come back later!");
            }
            Environment.Exit(0);
        }