ExecuteCommand() public méthode

public ExecuteCommand ( string inputCommand ) : void
inputCommand string
Résultat void
Exemple #1
0
 public void Execute(CommandExecutionContext context)
 {
     string aliasCommand;
     if (!context.Aliases.TryGetValue(AliasName, out aliasCommand))
     {
         context.WriteErrorLine("Unknown alias '{0}'", AliasName);
         return;
     }
     int index = 1;
     foreach (var paramValue in AliasParameters.Split(' '))
     {
         aliasCommand = aliasCommand.Replace("$" + index, paramValue);
     }
     context.WriteInfoLine("Alias '{0}' expanded to '{1}'", AliasName, aliasCommand);
     context.ExecuteCommand(aliasCommand);
 }
Exemple #2
0
        public void Execute(CommandExecutionContext context)
        {
            string aliasCommand;

            if (!context.Aliases.TryGetValue(AliasName, out aliasCommand))
            {
                context.WriteError("Unknown alias '{0}'", AliasName);
                return;
            }
            int index = 1;

            foreach (var paramValue in AliasParameters.Split(' '))
            {
                aliasCommand = aliasCommand.Replace("$" + index, paramValue);
            }
            context.WriteInfo("Alias '{0}' expanded to '{1}'", AliasName, aliasCommand);
            context.ExecuteCommand(aliasCommand);
        }
Exemple #3
0
        private void ExecuteInitialCommand()
        {
            if (!String.IsNullOrEmpty(_options.InputFileName))
            {
                List <string> commands = new List <string>();
                try
                {
                    string command = "";
                    foreach (string line in File.ReadLines(_options.InputFileName))
                    {
                        if (line.EndsWith(" _"))
                        {
                            command += line.Substring(0, line.Length - 1);
                        }
                        else
                        {
                            commands.Add(command + line);
                            command = "";
                        }
                    }
                }
                catch (IOException ex)
                {
                    Bail("Error reading from initial command file: {0}", ex.Message);
                }

                foreach (var command in commands)
                {
                    _context.WriteInfoLine("#> {0}", command);
                    _context.ExecuteOneCommand(command);
                }
            }
            else if (!String.IsNullOrEmpty(_options.InitialCommand))
            {
                _context.WriteInfoLine("#> {0}", _options.InitialCommand);
                _context.ExecuteCommand(_options.InitialCommand);
            }
        }