private bool ProcessCommand()

in code/src/CoreTemplateStudio/CoreTemplateStudio.Cli/App.cs [46:110]


        private bool ProcessCommand(string command)
        {
            try
            {
                AppHealth.Current.Verbose.TrackAsync(string.Format(StringRes.ReceivedCommand, command)).FireAndForget();

                var args = Regex.Split(command, splitPattern)
                    .Select(s => s.Trim('"'));

                var parserResult = _parser.ParseArguments<
                        SyncCommand,
                        GetProjectTypesCommand,
                        GetFrameworksCommand,
                        GetLayoutsCommand,
                        GetPagesCommand,
                        GetFeaturesCommand,
                        GetServicesCommand,
                        GetTestingsCommand,
                        GetAllLicencesCommand,
                        GenerateCommand,
                        CloseCommand>(args);

                var exitCode = parserResult.MapResult(
                        (SyncCommand opts) => _dispatcher.DispatchAsync(opts),
                        (GetProjectTypesCommand opts) => _dispatcher.DispatchAsync(opts),
                        (GetFrameworksCommand opts) => _dispatcher.DispatchAsync(opts),
                        (GetLayoutsCommand opts) => _dispatcher.DispatchAsync(opts),
                        (GetPagesCommand opts) => _dispatcher.DispatchAsync(opts),
                        (GetFeaturesCommand opts) => _dispatcher.DispatchAsync(opts),
                        (GetServicesCommand opts) => _dispatcher.DispatchAsync(opts),
                        (GetTestingsCommand opts) => _dispatcher.DispatchAsync(opts),
                        (GetAllLicencesCommand opts) => _dispatcher.DispatchAsync(opts),
                        (GenerateCommand opts) => _dispatcher.DispatchAsync(opts),
                        (CloseCommand opts) => Task.FromResult(1),
                        errors =>
                        {
                            var helpText = HelpText.AutoBuild(parserResult);
                            var errorText = string.Format(StringRes.ErrorParsingCommand, command, helpText);
                            _messageService.SendError(errorText);
                            AppHealth.Current.Error.TrackAsync(errorText).FireAndForget();
                            return Task.FromResult(0);
                        });

                _catchedExceptionsCounter = 0;

                // todo: use async task
                return exitCode.Result == 0;
            }
            catch (Exception ex)
            {
                var errorMessage = string.Format(StringRes.ErrorExecutingCommand, command, ex.Message);
                AppHealth.Current.Exception.TrackAsync(ex, errorMessage).FireAndForget();
                _messageService.SendError(errorMessage);

                _catchedExceptionsCounter++;
                if (_catchedExceptionsCounter == ExceptionsAllowed)
                {
                    _messageService.SendError(StringRes.ErrorMaxExceptionAllowed);
                    AppHealth.Current.Error.TrackAsync(StringRes.ErrorMaxExceptionAllowed).FireAndForget();
                    return false;
                }

                return true;
            }
        }