// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 using System.Collections.Generic; using System.Threading.Tasks; using AWS.Deploy.Common; using AWS.Deploy.Common.IO; using AWS.Deploy.Common.Recipes; using AWS.Deploy.Common.Recipes.Validation; using AWS.Deploy.Common.TypeHintData; namespace AWS.Deploy.CLI.Commands.TypeHints { /// /// Typehint that lets the user specify a path to a file. /// This can either be an absolute path to the file or relative to the project path. /// public class FilePathCommand : ITypeHintCommand { private readonly IConsoleUtilities _consoleUtilities; private readonly IOptionSettingHandler _optionSettingHandler; private readonly IFileManager _fileManager; public FilePathCommand(IConsoleUtilities consoleUtilities , IOptionSettingHandler optionSettingHandler, IFileManager fileManager) { _consoleUtilities = consoleUtilities; _optionSettingHandler = optionSettingHandler; _fileManager = fileManager; } /// /// Not implemented, specific files are not suggested to the user /// /// Empty list public Task GetResources(Recommendation recommendation, OptionSettingItem optionSetting) => Task.FromResult(new TypeHintResourceTable()); /// /// Prompts the user to enter a path to a file /// public Task Execute(Recommendation recommendation, OptionSettingItem optionSetting) { var typeHintData = optionSetting.GetTypeHintData(); var userFilePath = _consoleUtilities .AskUserForValue( string.Empty, _optionSettingHandler.GetOptionSettingValue(recommendation, optionSetting) ?? string.Empty, allowEmpty: typeHintData?.AllowEmpty ?? true, resetValue: _optionSettingHandler.GetOptionSettingDefaultValue(recommendation, optionSetting) ?? "") ; return Task.FromResult(userFilePath); } } }