diff options
author | Wouter Tinus <win.acme.simple@gmail.com> | 2020-01-13 20:14:40 +0100 |
---|---|---|
committer | Wouter Tinus <win.acme.simple@gmail.com> | 2020-01-13 20:14:40 +0100 |
commit | 1d1e5137bff301fc942143c560f9509af0671391 (patch) | |
tree | 9af859c97f3ca5894c9f332b2a712b728645f82f /src/main.lib/Services/Interfaces/IInputService.cs | |
parent | 954d2395b50b430e981295614c28a1ec860242f4 (diff) | |
download | letsencrypt-win-simple-1d1e5137bff301fc942143c560f9509af0671391.zip letsencrypt-win-simple-1d1e5137bff301fc942143c560f9509af0671391.tar.gz letsencrypt-win-simple-1d1e5137bff301fc942143c560f9509af0671391.tar.bz2 |
simple unit test for the main class working
Diffstat (limited to 'src/main.lib/Services/Interfaces/IInputService.cs')
-rw-r--r-- | src/main.lib/Services/Interfaces/IInputService.cs | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/main.lib/Services/Interfaces/IInputService.cs b/src/main.lib/Services/Interfaces/IInputService.cs index c1d5c41..9ede4e3 100644 --- a/src/main.lib/Services/Interfaces/IInputService.cs +++ b/src/main.lib/Services/Interfaces/IInputService.cs @@ -6,9 +6,9 @@ namespace PKISharp.WACS.Services { public interface IInputService { - Task<TResult?> ChooseFromList<TSource, TResult>(string what, IEnumerable<TSource> options, Func<TSource, Choice<TResult?>> creator, string nullChoiceLabel) where TResult : class; - Task<TResult> ChooseFromList<TSource, TResult>(string what, IEnumerable<TSource> options, Func<TSource, Choice<TResult>> creator); - Task<TResult> ChooseFromList<TResult>(string what, List<Choice<TResult>> choices); + Task<TResult?> ChooseOptional<TSource, TResult>(string what, IEnumerable<TSource> options, Func<TSource, Choice<TResult?>> creator, string nullChoiceLabel) where TResult : class; + Task<TResult> ChooseRequired<TSource, TResult>(string what, IEnumerable<TSource> options, Func<TSource, Choice<TResult>> creator); + Task<TResult> ChooseFromMenu<TResult>(string what, List<Choice<TResult>> choices); Task<bool> PromptYesNo(string message, bool defaultOption); Task<string?> ReadPassword(string what); Task<string> RequestString(string what); @@ -22,14 +22,17 @@ namespace PKISharp.WACS.Services public class Choice { - public static Choice<T> Create<T>(T item, + public static Choice<TItem> Create<TItem>( + TItem item, string? description = null, string? command = null, bool @default = false, bool disabled = false, ConsoleColor? color = null) { - var newItem = new Choice<T>(item); + var newItem = new Choice<TItem>(item); + // Default description is item.ToString, but it may + // be overruled by the optional parameter here if (!string.IsNullOrEmpty(description)) { newItem.Description = description; |