Example #1
0
        /// <summary>
        /// Executes one iteration of the loop.
        /// </summary>
        /// <returns>The result of executing.</returns>
        public CommandResult ExecuteOnce()
        {
            Client.DisplayPrompt();

            var args = ReadInput();

            if (args == null)
            {
                return(CommandResult.Terminate);
            }
            if (args.Length == 0)
            {
                return(CommandResult.Success);
            }

            var options = new CommandLineParserOptions
            {
                Reporter = error => Client.OnError(error.ToString().TrimEnd())
            };

            var commandGroup = new CommandGroup <TCommandType>();

            if (!CommandLineParser.Parse(args, commandGroup, options))
            {
                Client.OnError(Strings.InvalidUsage);
                return(CommandResult.UsageError);
            }

            return(commandGroup.Execute());
        }