ConsoleI
Description
ConsoleI is the principal object for all input request
Methods
AskConfirmation
User must press key to accept of reject
Signature:
bool AskConfirmation(string message, ConsoleKey okKey = ConsoleKey.Y, ConsoleKey koKey = ConsoleKey.N)
Params:
- message -> message to show as question
- okKey ->
ConsoleKey
to use astrue
- koKey ->
ConsoleKey
to use asfalse
Details:
- User must press one of two keys to continue, one returns
true
, otherfalse
- By default keys are
Y
-> true,N
-> false
Ask
Receives text input from console and converts to type
Signature:
Task<T> Ask<T>(string message, T defaultValue = default, IValidatorCollection<T>? validators = null, StringConverterProvider? provider = null)
Params:
- message -> message to show before request input
- defaultValue -> value to use as default if no input
- validators -> input validators
- provider -> input converter provider
Details:
- Allow to request input using free text, A default value can be passed.
- You can pass a collection of validators, that will force the user to input a expected value
- You can pass a custom converter provider to convert result
Read more at:
Select
User must select from a list of values
Signature:
// select one
Task<T> Select<T>(IEnumerable<T> options);
// select one or more
Task<IEnumerable<T>> Select<T>(IEnumerable<T> options, int max);
// select one from enum type
Task<T> Select<T>() where T : Enum;
// select one or more from enum type
Task<IEnumerable<T>> Select<T>(int max) where T : Enum;
Params:
- options -> collection of options to show
- max -> max number of selected options allowed
Details:
- User must always select at least one option
- You can pass a collection of validators, that will force the user to input a expected value
- You can pass a custom converter provider to convert result
Read more at:
Form
Build object from multi questions, using FormEntry
attribute
Signature:
Task<T> RenderForm<T>() where T : new()
Details:
- T must have properties with attribute
FormEntry
Read more at: