File Author Link import * as vscode from 'vscode' ; import { Template } from './template' ; export interface IInput { template ? : Template ; fileName ? : string ; } const validateNameRegex = ( ( ) : RegExp => { if ( process . platform === 'win32' ) { return /[/?*:|<>\\]/ ; } else if ( process . platform === 'darwin' ) { return /[/:]/ ; } else { return /\// ; } } ) ( ) ; export class InputController { public constructor ( ) { } private async showTemplatePicker ( templates ) { let template = await vscode . window . showQuickPick ( templates , { placeHolder : 'Select file/folder template:' , } ) ; return template ; } private async showNameInput ( ) { let fileName = await vscode . window . showInputBox ( { placeHolder : 'Input file/folder name' , validateInput : text => ( validateNameRegex . test ( text ) ? 'Invalidate file name' : null ) , } ) ; return fileName ; } public async run ( templates ) { let template = await this . showTemplatePicker ( templates ) ; if ( ! template ) { return { } ; } let fileName = await this . showNameInput ( ) ; if ( ! fileName ) { return { } ; } return { template , fileName } ; } }