Пример #1
0
        static void CommandHelp(CommandArg[] args)
        {
            if (args.Length == 0)
            {
                foreach (var command in HeadlessTerminal.Shell.Commands)
                {
                    HeadlessTerminal.Log("{0}: {1}", command.Key.PadRight(16), command.Value.help);
                }
                return;
            }

            string command_name = args[0].String.ToUpper();

            if (!HeadlessTerminal.Shell.Commands.ContainsKey(command_name))
            {
                HeadlessTerminal.Shell.IssueErrorMessage("Command {0} could not be found.", command_name);
                return;
            }

            var info = HeadlessTerminal.Shell.Commands[command_name];

            if (info.help == null)
            {
                HeadlessTerminal.Log("{0} does not provide any help documentation.", command_name);
            }
            else if (info.hint == null)
            {
                HeadlessTerminal.Log(info.help);
            }
            else
            {
                HeadlessTerminal.Log("{0}\nUsage: {1}", info.help, info.hint);
            }
        }
Пример #2
0
        static void CommandTime(CommandArg[] args)
        {
            var sw = new Stopwatch();

            sw.Start();

            HeadlessTerminal.Shell.RunCommand(JoinArguments(args));

            sw.Stop();
            HeadlessTerminal.Log("Time: {0}ms", (double)sw.ElapsedTicks / 10000);
        }
Пример #3
0
        static void CommandSet(CommandArg[] args)
        {
            if (args.Length == 0)
            {
                foreach (var kv in HeadlessTerminal.Shell.Variables)
                {
                    HeadlessTerminal.Log("{0}: {1}", kv.Key.PadRight(16), kv.Value);
                }
                return;
            }

            string variable_name = args[0].String;

            if (variable_name[0] == '$')
            {
                HeadlessTerminal.Log(TerminalLogType.Warning, "Warning: Variable name starts with '$', '${0}'.", variable_name);
            }

            HeadlessTerminal.Shell.SetVariable(variable_name, JoinArguments(args, 1));
        }
Пример #4
0
        static void CommandTrace(CommandArg[] args)
        {
            int log_count = HeadlessTerminal.Buffer.Logs.Count;

            if (log_count - 2 < 0)
            {
                HeadlessTerminal.Log("Nothing to trace.");
                return;
            }

            var log_item = HeadlessTerminal.Buffer.Logs[log_count - 2];

            if (log_item.stack_trace == "")
            {
                HeadlessTerminal.Log("{0} (no trace)", log_item.message);
            }
            else
            {
                HeadlessTerminal.Log(log_item.stack_trace);
            }
        }
Пример #5
0
 static void CommandPrint(CommandArg[] args)
 {
     HeadlessTerminal.Log(JoinArguments(args));
 }