Ejemplo n.º 1
0
        public Task <ConsoleCommandResult> Call(string command)
        {
            var rcommand =
                Regex.Match(command,
                            @"^\s*(?<name>[\S]+)\s*(?<args>[\s\S]*?)?\s*((?<redir>>>>?)\s+(?<file>[\s\S]+))?$");
            var name  = rcommand.Groups["name"].Value;
            var args  = rcommand.Groups["args"].Value;
            var redir = rcommand.Groups["redir"].Value;
            var file  = rcommand.Groups["file"].Value;
            Task <ConsoleCommandResult> task = null;

            if (string.IsNullOrWhiteSpace(file))
            {
                task = _context.Execute(name, args, Scope);
            }
            else
            {
                var append = redir == ">>>";
                task = _context.ExecuteToFile(file, name, args, Scope, append);
            }
            return(task);
        }