private bool TryExecuteSingleCommand(string commandLine, bool manualMode = false) { IList <string> tokensList = CommandTokenizer.Tokenize(commandLine); if (tokensList.Count > 0) { string commandName = tokensList[0]; CCommand command = CRegistery.FindCommand(commandName); if (command != null) { command.Delegate = m_delegate; command.IsManualMode = manualMode; command.CommandString = commandLine; bool succeed = command.ExecuteTokens(tokensList, commandLine); command.Clear(); return(succeed); } if (manualMode) { m_delegate.LogTerminal(StringUtils.C(commandName + ": command not found", ColorCode.ErrorUnknownCommand)); } } return(false); }
bool Execute(string command) { CCommand cmd = CRegistery.FindCommand(command); if (cmd == null) { PrintError("{0}: command not found \"{1}\"", this.Name, command); return(false); } cmd.Delegate = this.Delegate; cmd.PrintUsage(true); cmd.Delegate = null; return(true); }
public CCommand FindCommand(string name) { return(CRegistery.FindCommand(name)); }
bool Execute(string stroke, string command = null) // TODO: refactor me! { string name = stroke.ToLower(); if (!string.IsNullOrEmpty(command)) { CShortCut shortCut; if (!CShortCut.TryParse(stroke, out shortCut)) { PrintError("Invalid shortcut: {0}", name); return(false); } string keyUpCommand = null; char keyDownOp = command[0]; if (keyDownOp == '+' || keyDownOp == '-') { if (command.Length == 1) { PrintError("Identifier expected!"); return(false); } string identifier = command.Substring(1); // register operation command CCommand keyDownCmd = CRegistery.FindCommand(command); if (keyDownCmd == null) { keyDownCmd = new COperationCommand(keyDownOp, identifier); CRegistery.Register(keyDownCmd); keyDownCmd.SetFlag(CCommandFlags.System, true); } // register opposite operation command char keyUpOp = OppositeOperation(keyDownOp); keyUpCommand = keyUpOp + identifier; CCommand keyUpCmd = CRegistery.FindCommand(keyUpCommand); if (keyUpCmd == null) { keyUpCmd = new COperationCommand(keyUpOp, identifier); CRegistery.Register(keyUpCmd); keyUpCmd.SetFlag(CCommandFlags.System, true); } } CBindings.Bind(shortCut, StringUtils.UnArg(command), keyUpCommand != null ? StringUtils.UnArg(keyUpCommand) : null); PostNotification( CCommandNotifications.CBindingsChanged, CCommandNotifications.KeyManualMode, this.IsManualMode ); return(true); } IList <CBinding> bindings = CBindings.List(name); if (bindings.Count > 0) { foreach (CBinding b in bindings) { PrintIndent(ToString(b)); } } else { PrintIndent("No bindings"); } return(true); }