[vscode-spring-cli]: boot new command support
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { OpenDialogOptions, Uri, window, workspace } from "vscode";
|
||||
import { InputBox, OpenDialogOptions, Uri, window, workspace } from "vscode";
|
||||
|
||||
export async function openDialogForFolder(customOptions: OpenDialogOptions): Promise<Uri> {
|
||||
const options: OpenDialogOptions = {
|
||||
@@ -15,3 +15,30 @@ export async function openDialogForFolder(customOptions: OpenDialogOptions): Pro
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
}
|
||||
|
||||
export function enterText(opts: {
|
||||
title: string,
|
||||
prompt: string,
|
||||
validate?: (v: string) => string | undefined,
|
||||
defaultValue?: string,
|
||||
placeholder?: string
|
||||
}): Promise<string> {
|
||||
return new Promise<string>((resolve) => {
|
||||
const inputBox: InputBox = window.createInputBox();
|
||||
inputBox.title = opts.title;
|
||||
inputBox.placeholder = opts.placeholder;
|
||||
inputBox.prompt = opts.prompt;
|
||||
inputBox.value = opts.defaultValue;
|
||||
inputBox.ignoreFocusOut = true;
|
||||
inputBox.onDidChangeValue(() => {
|
||||
inputBox.validationMessage = opts.validate ? opts.validate(inputBox.value) : undefined;
|
||||
});
|
||||
inputBox.onDidAccept(() => {
|
||||
if (!inputBox.validationMessage) {
|
||||
inputBox.hide();
|
||||
}
|
||||
});
|
||||
inputBox.onDidHide(() => resolve(inputBox.value));
|
||||
inputBox.show();
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user