public int OnExecute()

in src/BuildScriptGeneratorCli/Commands/CommandBase.cs [32:109]


        public int OnExecute(CommandLineApplication app, IConsole console)
        {
            console.CancelKeyPress += Console_CancelKeyPress;

            ILogger<CommandBase> logger = null;

            try
            {
                _serviceProvider = TryGetServiceProvider(console);
                if (_serviceProvider == null)
                {
                    return ProcessConstants.ExitFailure;
                }

                logger = _serviceProvider?.GetRequiredService<ILogger<CommandBase>>();
                logger?.LogInformation("Oryx command line: {cmdLine}", Environment.CommandLine);

                var envSettings = _serviceProvider?.GetRequiredService<CliEnvironmentSettings>();
                if (envSettings != null && envSettings.GitHubActions)
                {
                    logger?.LogInformation("The current Oryx command is being run from within a GitHub Action.");

                    DateTime startTime, endTime;
                    if (envSettings.GitHubActionsBuildImagePullStartTime != null
                        && envSettings.GitHubActionsBuildImagePullEndTime != null
                        && DateTime.TryParse(envSettings.GitHubActionsBuildImagePullStartTime, out startTime)
                        && DateTime.TryParse(envSettings.GitHubActionsBuildImagePullEndTime, out endTime))
                    {
                        TimeSpan interval = endTime - startTime;
                        var gitHubActionBuildImagePullDurationSeconds = interval.TotalSeconds.ToString();
                        var buildEventProps = new Dictionary<string, string>()
                        {
                            { "gitHubActionBuildImagePullDurationSeconds", gitHubActionBuildImagePullDurationSeconds },
                        };

                        logger.LogEvent("GitHubActionsBuildImagePullDurationLog", buildEventProps);
                    }
                }

                if (!IsValidInput(_serviceProvider, console))
                {
                    return ProcessConstants.ExitFailure;
                }

                if (DebugMode)
                {
                    console.WriteLine("Debug mode enabled");
                }

                using (var timedEvent = logger?.LogTimedEvent(GetType().Name))
                {
                    var exitCode = Execute(_serviceProvider, console);
                    timedEvent?.AddProperty(nameof(exitCode), exitCode.ToString());
                    return exitCode;
                }
            }
            catch (InvalidUsageException e)
            {
                console.WriteErrorLine(e.Message);
                return ProcessConstants.ExitFailure;
            }
            catch (Exception exc)
            {
                logger?.LogError(exc, "Exception caught");

                console.WriteErrorLine(Constants.GenericErrorMessage);
                if (DebugMode)
                {
                    console.WriteErrorLine(exc.ToString());
                }

                return ProcessConstants.ExitFailure;
            }
            finally
            {
                DisposeServiceProvider();
            }
        }