Esempio n. 1
0
        static async Task Main(string[] args)
        {
            Users users = new Users();

            ICommandHandler handler = new CommandHandlerBuilder()
                                      //.Configure(options =>
                                      //{
                                      //	options.Debug = true;
                                      //})
                                      .UseDefault(
                outputStream: Console.OpenStandardOutput(),
                encoding: Console.OutputEncoding);

            while (true)
            {
                string input = System.Console.ReadLine();
                if (input == "q")
                {
                    break;
                }
                if (input.StartsWith("/"))
                {
                    string command = input.TrimStart('/');
                    bool   res     = await handler.HandleCommandAsync(users.CurrentUser, command);

                    if (res)
                    {
                        Console.ForegroundColor = ConsoleColor.Green;
                        Console.WriteLine("Successfully executed command");
                    }
                    else
                    {
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine("Failed to execute command");
                    }
                    Console.ResetColor();
                    Console.WriteLine();
                }
            }
        }