public async Task Route()

in plugin-dotnet-agent/src/main/csharp/TeamCity.Dotnet.TestSuppressor/TeamCity.Dotnet.TestSuppressor/Infrastructure/CommandLine/CommandRouter.cs [37:75]


    public async Task Route()
    {
        var rootCommand = _options.Value;
        
        // if help is requested
        var subCommand = GetSelectedSubcommand(rootCommand);
        if (rootCommand.Help || subCommand is { IsActive: true, Help: true })
        {
            _helpPrinter.PrintHelp(subCommand ?? rootCommand);
            _applicationLifetime.StopApplication();
            return;
        }
        
        // then validate the command
        var validationResult = _commandValidator.Validate(rootCommand);
        if (!validationResult.IsValid)
        {
            _logger.LogError("Command validation failed");
            _logger.LogError("{ValidationResultErrorMessage}", validationResult.ErrorMessage);
            _helpPrinter.PrintHelp(rootCommand);
            _applicationLifetime.StopApplication();
            return;
        }

        // then execute the command if subcommand is specified
        if (subCommand is not { IsActive: true })
        {
            _logger.LogWarning("No command or root level options specified");
            _helpPrinter.PrintHelp(rootCommand);
            _applicationLifetime.StopApplication();
            return;
        }
        
        var handler = GetCommandHandler(subCommand);
        
        await ExecuteHandler(handler, subCommand);
        
        _applicationLifetime.StopApplication();
    }