- Direct Known Subclasses:
Dialog.Choice,Dialog.Query
The dialogue API is only used for the command line interface. Therefore, the actual implementation is handled by the command line component. This API provides a way of creating server-side dialogues which makes it possible to create extensions that provide a commandline configuration component.
When a Dialog is completed, it can also be optionally evaluated to a value, which can be queried by calling getResult().
The evaluation function can be set with evaluateTo(Supplier).
Alternatively, a dialogue can also copy the evaluation function of another dialogue with evaluateTo(Dialog).
An evaluation result can also be mapped to another type with map(Function).
It is also possible to listen for the completion of this dialogue with onCompletion(FailableConsumer).
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Dialogbusy()Creates a dialogue that will show a loading icon until the next dialogue question is sent.static DialogChains multiple dialogues together.static <T> Dialog.Choicechoice(String description, Function<T, String> toString, boolean required, boolean quiet, T def, T... vals) Creates a choice dialogue from a set of objects.static Dialog.ChoiceCreates a choice dialogue.voidRemoves all completion listeners.<T> voidcomplete()static Dialogempty()Creates an empty dialogue.evaluateTo(Dialog d) evaluateTo(Supplier<?> s) static Dialogfork(String description, List<Choice> elements, boolean required, int selected, Function<Integer, Dialog> c) Creates a dialogue that will fork the control flow.<T> Tstatic DialogCreate a simple dialogue that will print a message.static DialogCreate a simple dialogue that will print a message.static DialogCreates a dialogue that will only evaluate when needed.<T> Dialogprotected abstract DialogElementstatic <T> Dialog.Queryquery(String description, boolean newLine, boolean required, boolean quiet, T value, QueryConverter<T> converter) Creates a simple query dialogue.static Dialog.QueryquerySecret(String description, boolean newLine, boolean required, SecretValue value) A special wrapper for secret values ofquery(String, boolean, boolean, boolean, Object, QueryConverter).final DialogElementstatic <T> DialogCreates a dialogue that starts from the beginning if the repeating condition is true.static <T> DialogCreates a dialogue that will repeat with an error message if the condition is met.static DialogCreates a dialogue that will not be executed if the condition is true.abstract DialogElementstart()
-
Field Details
-
eval
-
-
Constructor Details
-
Dialog
public Dialog()
-
-
Method Details
-
empty
Creates an empty dialogue. This dialogue completes immediately and does not handle any questions or answers. -
choice
public static Dialog.Choice choice(String description, List<Choice> elements, boolean required, boolean quiet, int selected) Creates a choice dialogue.- Parameters:
description- the shown question descriptionelements- the available elements to choose fromrequired- signals whether a choice is required or can be left emptyselected- the selected element index
-
choice
@SafeVarargs public static <T> Dialog.Choice choice(String description, Function<T, String> toString, boolean required, boolean quiet, T def, T... vals) Creates a choice dialogue from a set of objects.- Parameters:
description- the shown question descriptiontoString- a function that maps the objects to a stringrequired- signals whether choices required or can be left emptydef- the element which is selected by defaultvals- the range of possible elements
-
query
public static <T> Dialog.Query query(String description, boolean newLine, boolean required, boolean quiet, T value, QueryConverter<T> converter) Creates a simple query dialogue.- Parameters:
description- the shown question descriptionnewLine- signals whether the query should be done on a new line or notrequired- signals whether the query can be left empty or notquiet- signals whether the user should be explicitly queried for the value. In case the user is not queried, a value can still be set using the command line arguments that allow to set the specific value for a configuration query parametervalue- the default valueconverter- the converter
-
querySecret
public static Dialog.Query querySecret(String description, boolean newLine, boolean required, SecretValue value) A special wrapper for secret values ofquery(String, boolean, boolean, boolean, Object, QueryConverter). -
chain
-
repeatIf
-
header
-
header
-
busy
Creates a dialogue that will show a loading icon until the next dialogue question is sent. -
lazy
Creates a dialogue that will only evaluate when needed. This allows a dialogue to incorporate completion information about a previous dialogue. -
skipIf
-
retryIf
-
fork
public static Dialog fork(String description, List<Choice> elements, boolean required, int selected, Function<Integer, Dialog> c) Creates a dialogue that will fork the control flow.- Parameters:
description- the shown question descriptionelements- the available elements to choose fromrequired- signals whether a choice is required or notselected- the index of the element that is selected by defaultc- the dialogue index mapping function
-
clearCompletion
public void clearCompletion()Removes all completion listeners. Intended for internal use only. -
start
- Throws:
Exception
-
evaluateTo
-
evaluateTo
-
map
-
onCompletion
-
onCompletion
-
onCompletion
-
getResult
public <T> T getResult() -
complete
-
receive
- Throws:
Exception
-
next
- Throws:
Exception
-