コード例 #1
0
        public static void PrintIntro()
        {
            Version version   = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
            string  eVer      = version.ToString();
            string  buildInfo = "";

            if (version.Revision != 0)
            {
                switch (version.Revision)
                {
                default: { buildInfo = "UNSTABLE VERSION"; break; }

                case 1: { buildInfo = "BETA VERSION (only for testing)"; break; }
                }
            }

            EConsole.ForegroundColor = ConsoleColor.Green;



            Version cVer = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;

            EConsole.WriteLine(" ");

            EConsole.Write($"   cmd# {cVer.Major}.{cVer.Minor}", ConsoleColor.Green);

            switch (EnvironmentManager.Edition)
            {
            case EnvironmentManager.ESEditions.Core:
            {
                EConsole.WriteLine(" Core", ConsoleColor.Magenta);
                break;
            }

            case EnvironmentManager.ESEditions.Standard:
            {
                EConsole.WriteLine(" Standard", ConsoleColor.White);
                break;
            }
            }

            EConsole.WriteLine("   Copyright (C) Dz3n 2017-2019", ConsoleColor.Gray);
            EConsole.Write("   Build " + version.Build + " ", ConsoleColor.DarkGray);

            EConsole.WriteLine(buildInfo, ConsoleColor.Yellow);

            if (cVer.Revision != 0)
            {
                EConsole.WriteLine("   Type \"update\" to install the latest stable version", true, ConsoleColor.DarkYellow);
            }

            EConsole.WriteLine("");
            EConsole.WriteLine("   OS: " + Environment.OSVersion.VersionString, ConsoleColor.DarkGray);
            EConsole.WriteLine("   https://github.com/feel-the-dz3n/escript | https://discord.gg/jXcjuqv", ConsoleColor.DarkGray);
            EConsole.WriteLine("   https://vk.com/dz3n.escript", ConsoleColor.DarkGray);
            EConsole.WriteLine("");
        }
コード例 #2
0
        public static string Show(string caption, string text)
        {
            string       result = "OK";
            ConsoleColor s      = EConsole.ForegroundColor;

            EConsole.ForegroundColor = ConsoleColor.White;
            EConsole.WriteLine("");
            EConsole.ForegroundColor = ConsoleColor.Cyan;
            EConsole.WriteLine(caption);
            EConsole.Write(ConsoleMessageBox.GetTest(caption));
            EConsole.WriteLine("");
            EConsole.ForegroundColor = ConsoleColor.White;
            EConsole.WriteLine(text);

            EConsole.ForegroundColor = ConsoleColor.Gray;
            EConsole.WriteLine("");

            EConsole.WriteLine("");
            EConsole.WriteLine("");
            EConsole.ForegroundColor = s;
            return(result);
        }
コード例 #3
0
ファイル: CoreMain.cs プロジェクト: attackgithub/CmdSharp
        public static void CommandLine()
        {
            ScriptColor = ConsoleColor.White;
            Cmd.Process("ShowConsole();");
            new Thread(CheckUpdates).Start();
            Variables.Set("showResult", "1");
            GlobalVars.StopProgram   = false;
            EConsole.ForegroundColor = ConsoleColor.White;
            EConsole.WriteLine("Need help? Type: help();");

            if (!GlobalVars.IsCompiledScript && !System.Reflection.Assembly.GetExecutingAssembly().Location.Contains("\\CmdSharp\\CmdSharp.exe"))
            {
                EConsole.WriteLine("To install this copy of CmdSharp type: install();");
            }

            while (true)
            {
                EConsole.ForegroundColor = ConsoleColor.Green;
                EConsole.Write(Variables.GetValue("invitation"));
                EConsole.ForegroundColor = ConsoleColor.White;
                string line = EConsole.ReadLine();
                EConsole.ForegroundColor = ScriptColor;
                SetResult(Cmd.Process(GlobalVars.RemoveDirtFromString(line)));
                if (Variables.GetBool("showResult"))
                {
                    PrintResult(Variables.GetValueObject("result"));
                }
                if (Variables.GetValue("forceGC") == "1")
                {
                    GC.Collect();
                    GC.WaitForPendingFinalizers();
                }
                if (GlobalVars.StopProgram)
                {
                    break;
                }
            }
        }
コード例 #4
0
        public static string Show(string caption, string text, int icon, int buttons)
        {
            string       result = "0";
            ConsoleColor s      = EConsole.ForegroundColor;

            //Console.Clear();
            EConsole.ForegroundColor = ConsoleColor.White;
            EConsole.WriteLine("");
            EConsole.ForegroundColor = ConsoleColor.Cyan;
            if (icon == 3)
            {
                EConsole.ForegroundColor = ConsoleColor.Red;
            }
            if (icon == 2 || icon == 4)
            {
                EConsole.ForegroundColor = ConsoleColor.Yellow;
            }
            EConsole.WriteLine(caption);
            EConsole.Write(GetTest(caption));
            EConsole.WriteLine("");
            EConsole.ForegroundColor = ConsoleColor.White;
            EConsole.WriteLine(text);

            EConsole.ForegroundColor = ConsoleColor.Gray;
            EConsole.WriteLine("");
            if (buttons == 0)
            {
                EConsole.Write("   OK [Enter] ");
                while (true)
                {
                    var key = EConsole.ReadKey(true).ToLower();
                    if (key == "enter")
                    {
                        result = "OK";
                        break;
                    }
                }
            }
            else if (buttons == 1)
            {
                EConsole.Write("   OK [Enter] | Cancel [C] ");
                while (true)
                {
                    var key = EConsole.ReadKey(true).ToLower();

                    if (key == "enter")
                    {
                        result = "OK";
                        break;
                    }
                    else if (key == "c")
                    {
                        result = "Cancel";
                        break;
                    }
                }
            }
            else if (buttons == 2)
            {
                EConsole.Write("   Yes [Y] | No [N] ");
                while (true)
                {
                    var key = EConsole.ReadKey(true).ToLower();
                    if (key == "y")
                    {
                        result = "Yes";
                        break;
                    }
                    else if (key == "n")
                    {
                        result = "No";
                        break;
                    }
                }
            }
            else if (buttons == 3)
            {
                EConsole.Write("   Yes [Y] | No [N] | Cancel [C] ");
                while (true)
                {
                    var key = EConsole.ReadKey(true).ToLower();
                    if (key == "y")
                    {
                        result = "Yes";
                        break;
                    }
                    else if (key == "n")
                    {
                        result = "No";
                        break;
                    }
                    else if (key == "c")
                    {
                        result = "Cancel";
                        break;
                    }
                }
            }
            else if (buttons == 4)
            {
                EConsole.Write("   Retry [R] | Cancel [C] ");
                while (true)
                {
                    var key = EConsole.ReadKey(true).ToLower();
                    if (key == "r")
                    {
                        result = "Retry";
                        break;
                    }
                    else if (key == "c")
                    {
                        result = "Cancel";
                        break;
                    }
                }
            }
            else if (buttons == 5)
            {
                EConsole.Write("   Abort [A] | Retry [R] | Ignore [I] ");
                while (true)
                {
                    var key = EConsole.ReadKey(true).ToLower();
                    if (key == "r")
                    {
                        result = "Retry";
                        break;
                    }
                    else if (key == "i")
                    {
                        result = "Ignore";
                        break;
                    }
                    else if (key == "a")
                    {
                        result = "Abort";
                        break;
                    }
                }
            }
            else
            {
                EConsole.WriteLine("");
                EConsole.Write("   ERROR: Unknown keys");
            }
            EConsole.WriteLine("");
            EConsole.WriteLine("");
            EConsole.ForegroundColor = s;
            return(result);
        }
コード例 #5
0
ファイル: CoreMain.cs プロジェクト: attackgithub/CmdSharp
        public static void PrintResult(object result, string prefix = "")
        {
            if (prefix != "")
            {
                EConsole.Write(prefix, ConsoleColor.DarkGray);
            }
            EConsole.Write("Result: ", ConsoleColor.DarkGray);

            if (result != null)
            {
                EConsole.Write($"({result.GetType().Name}) ", ConsoleColor.DarkGray);
                if (result.GetType() == typeof(Exception))
                {
                    EConsole.Write("invoke ToString() to get details", ConsoleColor.DarkGray);
                }
                else
                {
                    EConsole.Write(result.ToString(), ConsoleColor.Gray);
                }
            }
            else
            {
                EConsole.Write("null", ConsoleColor.DarkGray);
            }
            //result = result.ToString();
            ///*if (result == "-1")
            //{
            //    EConsole.ForegroundColor = ConsoleColor.DarkRed;
            //    EConsole.Write(" (error/-1)");
            //}
            //else if (result == "0" || result.ToLower() == "false")
            //{
            //    EConsole.ForegroundColor = ConsoleColor.DarkYellow;
            //    EConsole.Write(" (false/error/0)");
            //}
            //else if (result == "1" || result.ToLower() == "true")
            //{
            //    EConsole.ForegroundColor = ConsoleColor.DarkGreen;
            //    EConsole.Write(" (true/ok/1)");
            //}
            //else */if (result == "CMD_NOT_FOUND")
            //{
            //    EConsole.Write(" (command not found)", ConsoleColor.DarkGray);
            //}
            //else if (result.Length == 0)
            //{
            //    EConsole.Write(" (nothing or null)", ConsoleColor.DarkGray);
            //}
            //else if (result == "ESCRIPT_ERROR_EXCEPTION")
            //{
            //    EConsole.Write(" (invalid arguments or ESCRIPT issue)", ConsoleColor.DarkRed);
            //}
            //else if (result.StartsWith("SYNTAX_ERROR"))
            //{
            //    EConsole.Write(" (syntax error)", ConsoleColor.DarkRed);
            //}
            //else if (result.StartsWith("ESCRIPT_ERROR"))
            //{
            //    EConsole.Write(" (ESCRIPT error)", ConsoleColor.DarkRed);
            //}
            //else if (result.StartsWith("CMD_ERROR_NULL"))
            //{
            //    EConsole.Write(" (unknown error)", ConsoleColor.DarkRed);
            //}
            //else if (result.StartsWith("CMD_ERROR"))
            //{
            //    EConsole.Write(" (error)", ConsoleColor.DarkRed);
            //}
            //else if (result.StartsWith("CMD_DONE"))
            //{
            //    EConsole.Write(" (done)", ConsoleColor.DarkGreen);
            //}
            //else if (result.StartsWith("CMD_FAIL"))
            //{
            //    EConsole.Write(" (fail)", ConsoleColor.DarkYellow);
            //}
            EConsole.WriteLine("");
        }