コード例 #1
0
 internal static void Mes(string mes = "", ConsoleColor cc = ConsoleColor.Gray)
 {
     //var ccl = Console.ForegroundColor;
     //Console.ForegroundColor = cc;
     ConsoleDebug.WriteLine($"{mes}", cc);
     //Console.ForegroundColor = ccl;
 }
コード例 #2
0
 private void Threadstart()
 {
     ConsoleDebug = new ConsoleDebug();
     while (true)
     {
         Thread.Sleep(1);
         ConsoleDebug.WaitCommand(Console.ReadLine());
     }
 }
コード例 #3
0
        public ConsoleDebug()
        {
            //Commands = new ExtraArray<CCommand>(Array.Empty<CCommand>());

            CCommand.SNew(CommandActions.Help, "help", "Default", true, "Showing command list or using as command helper", "Command");
            CCommand.SNew(CommandActions.Exit, "exit", "Default", false, "Stopping current process");
            CCommand.SNew(CommandActions.DebugBeep, "beep", "Default", true, "Debug beep, returns value", "State");
            CCommand.SNew(CommandActions.ClearConsole, "clear", "Default", false, "Clears console bufer");

            CCommand.SNew(CommandActions.PackFileInPkg, "pkgpack", "PackageManager", false, "Packing file into package", "File path", "PKG name");
            CCommand.SNew(CommandActions.UnpackFileInPkg, "pkgunpack", "PackageManager", false, "Unpacking file into folder", "Filename", "PKG name", "Folder path");
            CCommand.SNew(CommandActions.CreatePKG, "pkgcreate", "PackageManager", false, "Creating new pkg in pkgmgr", "PKG name");
            CCommand.SNew(CommandActions.ImportPKG, "pkgimport", "PackageManager", false, "Importing pkg from folder", "File path");
            CCommand.SNew(CommandActions.ExportPKG, "pkgexport", "PackageManager", false, "Exporting pkg into folder", "Folder path", "PKG name");
            Instance = this;
            CClass.CheckCreateAdd(this, nameof(ConsoleDebug));
        }
コード例 #4
0
        public static DResult Help(params CParameter[] Params)
        {
            if (Params.Length > 0)
            {
                var param = Params[0].Value.ToString();

                /*
                 * for (var i = 0; i != param.Length; i++)
                 * {
                 *  var par = param;
                 *  if (par[i] == ' ')
                 *      param = par.Remove(i, 1);
                 * }
                 */
                bool     finded = false;
                CCommand cc     = null;
                foreach (var item in ConsoleDebug.GetCCommandList())
                {
                    if (item.CommandLine == param)
                    {
                        finded = true;
                        cc     = item;
                        break;
                    }
                }
                if (finded)
                {
                    var ot = "";
                    var s  = "";
                    if (cc.System)
                    {
                        s = "System";
                    }
                    else
                    {
                        s = "Custom";
                    }
                    ot += $"{s} : {cc.CommandLine}";
                    foreach (var item in cc.Params)
                    {
                        ot += $" <{item}>";
                    }
                    ot += $" - {cc.Description}.";
                    return(DResult.C(CDebugResult.OK, ot, Help, ConsoleDebug.CClass, ConsoleDebug.Instance));
                }
                else
                {
                    var mes = "Unknown command in help list.";
                    return(DResult.C(CDebugResult.Warn, mes, Help, ConsoleDebug.CClass, ConsoleDebug.Instance));
                }
            }
            else
            {
                string ot  = "Command list:\n";
                var    cll = new List <String>();
                var    cs  = ConsoleDebug.GetCCommandList();
                for (var j = 0; j != cs.Length; j++)
                {
                    var cl = cs[j].Class;
                    if (cll.Contains(cl))
                    {
                        continue;
                    }
                    for (var i = 0; i != cs.Length; i++)
                    {
                        if (cs[i].Class == cl)
                        {
                            var s = "";
                            if (cs[i].System)
                            {
                                s = "System";
                            }
                            else
                            {
                                s = "Custom";
                            }
                            string val = $"  {s} : {cs[i].Class} : {cs[i].CommandLine} - {cs[i].Description}";
                            if (i - 1 != cs.Length)
                            {
                                ot += "\n";
                            }
                            ot += val;
                        }
                    }
                    if (j - 1 != cs.Length)
                    {
                        ot += "\n";
                    }
                    cll.Add(cl);
                }
                return(DResult.C(CDebugResult.OK, ot, Help, ConsoleDebug.CClass, ConsoleDebug.Instance, ConsoleColor.White));
            }
        }