public class TermUi
Modifier and Type | Method and Description |
---|---|
java.lang.Boolean |
confirm(java.lang.String text,
boolean p,
boolean abort,
java.lang.String promptSuffix,
boolean showDefault,
CliktConsole console)
Prompt for user confirmation.
|
void |
echo(java.lang.Object message,
boolean trailingNewline,
boolean err,
CliktConsole console)
Print the message to the screen.
|
void |
editFile(java.lang.String filename,
java.lang.String editor,
java.util.Map<java.lang.String,java.lang.String> env,
boolean requireSave,
java.lang.String extension)
Edit the file with filename in the editor.
|
java.lang.String |
editText(java.lang.String text,
java.lang.String editor,
java.util.Map<java.lang.String,java.lang.String> env,
boolean requireSave,
java.lang.String extension)
Edit text in the editor.
|
boolean |
isWindows()
True if the current platform is a version of windows.
|
<T> T |
prompt(java.lang.String text,
java.lang.String p,
boolean hideInput,
boolean requireConfirmation,
java.lang.String confirmationPrompt,
java.lang.String promptSuffix,
boolean showDefault,
CliktConsole console,
kotlin.jvm.functions.Function1<? super java.lang.String,? extends T> convert)
Prompt a user for text input.
|
java.lang.String |
prompt(java.lang.String text,
java.lang.String p,
boolean hideInput,
boolean requireConfirmation,
java.lang.String confirmationPrompt,
java.lang.String promptSuffix,
boolean showDefault) |
public static TermUi INSTANCE
public void echo(java.lang.Object message, boolean trailingNewline, boolean err, CliktConsole console)
public java.lang.String editText(java.lang.String text, java.lang.String editor, java.util.Map<java.lang.String,java.lang.String> env, boolean requireSave, java.lang.String extension)
Edit text in the editor.
This blocks until the editor is closed.
text
- The text to edit.editor
- The path to the editor to use. Defaults to automatic detection.env
- Environment variables to forward to the editor.requireSave
- If the editor is closed without saving, null will be returned if true, otherwise
text will be returned.extension
- The extension of the temporary file that the editor will open. This can affect syntax
coloring etc.public void editFile(java.lang.String filename, java.lang.String editor, java.util.Map<java.lang.String,java.lang.String> env, boolean requireSave, java.lang.String extension)
Edit the file with filename in the editor.
TermUi.editText
public <T> T prompt(java.lang.String text, java.lang.String p, boolean hideInput, boolean requireConfirmation, java.lang.String confirmationPrompt, java.lang.String promptSuffix, boolean showDefault, CliktConsole console, kotlin.jvm.functions.Function1<? super java.lang.String,? extends T> convert)
Prompt a user for text input.
If the user send a terminate signal (e,g, ctrl-c) while the prompt is active, null will be returned.
text
- The text to display for the prompt.hideInput
- If true, the user's input will not be echoed back to the screen. This is commonly used
for password inputs.requireConfirmation
- If true, the user will be required to enter the same value twice before it
is accepted.confirmationPrompt
- The text to show the user when requireConfirmation is true.promptSuffix
- A delimiter printed between the text and the user's input.showDefault
- If true, the default value will be shown as part of the prompt.convert
- A callback that will convert the text that the user enters to the return value of the
function. If the callback raises a exception UsageError
, its message will be printed and the user will be
asked to enter a new value. If default is not null and the user does not input a value, the value
of default will be passed to this callback.public java.lang.String prompt(java.lang.String text, java.lang.String p, boolean hideInput, boolean requireConfirmation, java.lang.String confirmationPrompt, java.lang.String promptSuffix, boolean showDefault)
public java.lang.Boolean confirm(java.lang.String text, boolean p, boolean abort, java.lang.String promptSuffix, boolean showDefault, CliktConsole console)
Prompt for user confirmation.
Responses will be read from stdin, even if it's redirected to a file.
text
- the question to askabort
- if true
, a negative answer aborts the program by raising exception Abort
promptSuffix
- a string added after the question and choicesshowDefault
- if false, the choices will not be shown in the prompt.public boolean isWindows()
True if the current platform is a version of windows.