示例#1
0
 public virtual void PrintException(Exception ex)
 {
     LConsole.BeginLine()
     .Write("An exception occurred while executing the command: ", ConsoleColor.Red)
     .Write(ex.Message, ConsoleColor.DarkRed)
     .End();
 }
示例#2
0
文件: Command.cs 项目: pipe01/LICC
        public static void PrintUsage(this Command cmd)
        {
            using (var writer = LConsole.BeginLine())
            {
                if (cmd.Description != null)
                {
                    writer.WriteLine(cmd.Description, ConsoleColor.Cyan);
                }

                writer.Write("Usage: ", ConsoleColor.DarkYellow);

                string usage = cmd.Name + " " + cmd.GetParamsString();
                writer.Write(usage, ConsoleColor.Cyan);
            }
        }
示例#3
0
        private void HandleVariable(string varName, string args)
        {
            if (!Config.EnableVariables)
            {
                LConsole.WriteLine("Variables are disabled", ConsoleColor.Red);
                return;
            }

            var(exists, value) = _Environment.TryGet(varName);

            if (string.IsNullOrWhiteSpace(args))
            {
                if (!exists)
                {
                    LConsole.WriteLine($"No variable found with name '{varName}'", ConsoleColor.Red);
                    return;
                }
            }
            else if (args.StartsWith(":="))
            {
                if (!HandleVariableOperation(varName, args.Substring(2).Trim()))
                {
                    return;
                }
            }
            else if (args.StartsWith("="))
            {
                value = args.Substring(1).Trim();

                if (string.IsNullOrWhiteSpace(value))
                {
                    _Environment.Remove(varName);
                    LConsole.WriteLine("Cleared variable");
                    return;
                }
                else
                {
                    _Environment.Set(varName, value);
                }
            }

            LConsole.BeginLine()
            .Write(varName, ConsoleColor.DarkYellow)
            .Write(" = ", ConsoleColor.DarkGray)
            .Write(value)
            .End();
        }