/// <summary>
 /// Initializes a new instance of the <see cref="ExecutionContext"/> class.
 /// </summary>
 /// <param name="io">The io.</param>
 /// <param name="command">The command.</param>
 /// <param name="runner">The runner.</param>
 /// <param name="arguments">The arguments.</param>
 public ExecutionContext(ConsoleUtility io, CommandResult command, CommandRunner runner, List<string> arguments)
 {
     IO = io;
     Command = command;
     Runner = runner;
     Arguments = arguments;
 }
        private Tuple<CommandResult, List<object>, CommandInfo> ValidateDo(string commandline)
        {
            // Prepare
            var result = new CommandResult();

            // Parse input
            List<KeyValuePair<string, object>> args = _parser.Parse(commandline).ToList();
            if (!args.Any())
            {
                // Parsing error
                result.State = ResultState.ParsingError;
                return new Tuple<CommandResult, List<object>, CommandInfo>(result, null, null);
            }

            // System commands
            if (args.First().Key == "ncommandsystem")
            {
                // Show help / info: overview of available functions
                if (args.Skip(1).FirstOrDefault().Key?.ToLower() == "help")
                {
                    result.State = ResultState.ShowHelpOverview;
                    result.CommandInfo = new CommandInfo() { CommandName = "ncommandsystem.help" };
                    result.Result = _lookup.Commands;
                    return new Tuple<CommandResult, List<object>, CommandInfo>(result, null, null);
                }
            }

            // Command by name
            var command = _lookup.GetCommand(args.First().Key);
            result.CommandInfo = command;
            if (command == null)
            {
                result.State = ResultState.UnknownCommand;
                return new Tuple<CommandResult, List<object>, CommandInfo>(result, null, null);
            }

            // Find missing arguments
            var mapper = new CommandMapper();
            var mapped = mapper.Map(args.Skip(1), command.Arguments);
            if (mapped.State == ResultState.MissingArguments)
            {
                result.State = ResultState.MissingArguments;
                result.MissingArguments = mapped.MissingArguments;
                return new Tuple<CommandResult, List<object>, CommandInfo>(result, null, null);
            }

            // Result
            result.State = ResultState.Success;
            return new Tuple<CommandResult, List<object>, CommandInfo>(result, mapped.ResultArguments, command);
        }