static async Task Main(string[] args) { IHost host = CreateHostBuilder(args).Build(); using (var serviceScope = host.Services.CreateScope()) { var router = serviceScope.ServiceProvider.GetRequiredService <CLIRouterService>(); ICLIEndpoint endpoint = router.Route(); string result = await endpoint.RunAsync(); Console.Write(result); } }
public async Task <string> RunAsync() { string message; if (string.IsNullOrEmpty(MissingCommand) && Commands.Count > 1) { ICLIEndpoint endpoint = _router.Route(Commands[1]); message = await endpoint.PrintHelp(Commands.ElementAtOrDefault(2)); } else { message = await PrintHelp(); } return(message); }
public ICLIEndpoint Route(string command = null) { command = SystemOverwriteCommand(command); if (command is null) { command = Commands.ElementAtOrDefault(0); } ICLIEndpoint endpoint = Endpoints.FirstOrDefault(endpoint => endpoint.CommandName.Equals(command, StringComparison.InvariantCultureIgnoreCase)); if (endpoint is null) { HelpEndpoint.MissingCommand = command; endpoint = HelpEndpoint; } return(endpoint.Init(Commands)); }