private string AskForNewCloudApplicationName()

in src/AWS.Deploy.CLI/Commands/DeployCommand.cs [477:536]


        private string AskForNewCloudApplicationName(DeploymentTypes deploymentType, List<CloudApplication> deployedApplications)
        {
            if (_toolInteractiveService.DisableInteractive)
            {
                var message = "The \"--silent\" CLI argument can only be used if a cloud application name is provided either via the CLI argument \"--application-name\" or through a deployment-settings file. " +
                "Please provide an application name and try again";
                throw new InvalidCliArgumentException(DeployToolErrorCode.SilentArgumentNeedsApplicationNameArgument, message);
            }

            var defaultName = "";

            try
            {
                defaultName = _cloudApplicationNameGenerator.GenerateValidName(_session.ProjectDefinition, deployedApplications, deploymentType);
            }
            catch (Exception exception)
            {
                _toolInteractiveService.WriteDebugLine(exception.PrettyPrint());
            }

            var cloudApplicationName = string.Empty;

            while (true)
            {
                _toolInteractiveService.WriteLine();

                var title = "Name the Cloud Application to deploy your project to" + Environment.NewLine +
                            "--------------------------------------------------------------------------------";

                string inputPrompt;

                switch (deploymentType)
                {
                    case DeploymentTypes.CdkProject:
                        inputPrompt = Constants.CLI.PROMPT_NEW_STACK_NAME;
                        break;
                    case DeploymentTypes.ElasticContainerRegistryImage:
                        inputPrompt = Constants.CLI.PROMPT_ECR_REPOSITORY_NAME;
                        break;
                    default:
                        throw new InvalidOperationException($"The {nameof(DeploymentTypes)} {deploymentType} does not have an input prompt");
                }

                cloudApplicationName =
                    _consoleUtilities.AskUserForValue(
                        title,
                        defaultName,
                        allowEmpty: false,
                        defaultAskValuePrompt: inputPrompt);

                var validationResult = _cloudApplicationNameGenerator.IsValidName(cloudApplicationName, deployedApplications, deploymentType);
                if (validationResult.IsValid)
                {
                    return cloudApplicationName;
                }

                _toolInteractiveService.WriteLine();
                _toolInteractiveService.WriteErrorLine(validationResult.ErrorMessage);
            }
        }