Esempio n. 1
0
 public static List <TerminalCommand> filterCommands(string input)
 {
     TerminalUtility.filteredCommands.Clear();
     if (!string.IsNullOrEmpty(input))
     {
         IList <TerminalCommand> commands = Terminal.getCommands();
         for (int i = 0; i < commands.Count; i++)
         {
             TerminalCommand terminalCommand = commands[i];
             if (terminalCommand.method.command.Length >= input.Length)
             {
                 bool flag = true;
                 for (int j = 0; j < input.Length; j++)
                 {
                     if (terminalCommand.method.command[j] != input[j])
                     {
                         flag = false;
                         break;
                     }
                 }
                 if (flag)
                 {
                     TerminalUtility.filteredCommands.Add(terminalCommand);
                 }
             }
         }
     }
     return(TerminalUtility.filteredCommands);
 }
Esempio n. 2
0
 // Token: 0x06000890 RID: 2192 RVA: 0x0004D1F4 File Offset: 0x0004B5F4
 public static void registerCommand(TerminalCommand command)
 {
     if (command == null || command.method == null || command.parameters == null)
     {
         return;
     }
     Terminal.commands.Add(command.method.command, command);
 }
Esempio n. 3
0
 public static void execute(string input, List <string> arguments = null, List <TerminalCommand> commands = null)
 {
     if (arguments == null)
     {
         if (string.IsNullOrEmpty(input))
         {
             return;
         }
         arguments = TerminalUtility.splitArguments(input);
     }
     if (commands == null && arguments.Count >= 1)
     {
         if (string.IsNullOrEmpty(input))
         {
             return;
         }
         commands = TerminalUtility.filterCommands(arguments[0]);
     }
     if (commands.Count == 1)
     {
         TerminalCommand terminalCommand = commands[0];
         if (arguments.Count == terminalCommand.parameters.Length + 1)
         {
             bool     flag  = true;
             object[] array = new object[terminalCommand.parameters.Length];
             for (int i = 0; i < array.Length; i++)
             {
                 array[i] = Terminal.parserRegistry.parse(terminalCommand.parameters[i].type, arguments[i + 1]);
                 if (array[i] == null)
                 {
                     TerminalUtility.printCommandFail(string.Concat(new string[]
                     {
                         "Unable to parse \"",
                         arguments[i + 1],
                         "\" as ",
                         terminalCommand.parameters[i].type.Name.ToString().ToLower(),
                         "!"
                     }));
                     flag = false;
                     break;
                 }
             }
             if (flag)
             {
                 terminalCommand.method.info.Invoke(null, array);
             }
         }
         else
         {
             TerminalUtility.printCommandFail(string.Concat(new object[]
             {
                 "Expected ",
                 terminalCommand.parameters.Length,
                 " argument(s), got ",
                 arguments.Count - 1,
                 "!"
             }));
         }
     }
     else
     {
         TerminalUtility.printCommandFail(string.Concat(new object[]
         {
             "Unable to determine intention of \"",
             input,
             "\" out of ",
             commands.Count,
             " commands!"
         }));
     }
 }