Example #1
0
 public async Task Run(XConsole xc)
 {
     try
     {
         xc.AskForInput(this, "Enter command name: ");
         using (var scope = xc.WebHost.Services.CreateScope())
         {
             string command      = Console.ReadLine();
             var    commandClass = xc.FindCommand(command);
             if (commandClass != null)
             {
                 try
                 {
                     var commandInstance = xc.CreateCommandInstance(commandClass);
                     xc.WriteHelp(commandInstance);
                 }
                 catch (Exception)
                 {
                     xc.WriteError(this, $"Unable to display help for {command}");
                 }
             }
             else
             {
                 xc.WriteWarning(this, "Command not found.");
             }
         }
     }
     catch (Exception ex)
     {
         xc.WriteException(this, ex);
     }
 }