| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- /* ************************************************************************** */
- /* */
- /* ::: :::::::: */
- /* basicInput.ts :+: :+: :+: */
- /* +:+ +:+ +:+ */
- /* By: frfrey <frfrey@student.42lyon.fr> +#+ +:+ +#+ */
- /* +#+#+#+#+#+ +#+ */
- /* Created: 2020/07/22 10:21:45 by frfrey #+# #+# */
- /* Updated: 2020/07/22 10:21:45 by frfrey ### ########lyon.fr */
- /* */
- /* ************************************************************************** */
- import * as vscode from 'vscode';
- import * as fs from 'fs';
- import { getTemplate, getTemplateFull } from './template';
- import { getHeadercpp, getHeaderhpp } from './header';
- export async function createQuickClass() {
- let name = await vscode.window.showInputBox({
- prompt: "Enter your Class Name",
- placeHolder: "ClassName",
- validateInput: (text: string): string | undefined => {
- if (!text){
- return 'You must enter a name';
- } else {
- return undefined;
- }
- }
- });
- if (name !== undefined){
- name = name.charAt(0).toUpperCase() + name.slice(1)
- const wsedit = new vscode.WorkspaceEdit();
- const wsPath = vscode.workspace.workspaceFolders![0].uri.fsPath;
- const filePathCpp = vscode.Uri.file(wsPath + '/' + name + '.Class' + '.cpp');
- const filePathHpp = vscode.Uri.file(wsPath + '/' + name + '.Class' + '.hpp');
- let command = (vscode.workspace.getConfiguration().get('headercppclass.headerId') as string).trim();
- wsedit.createFile(filePathCpp, { ignoreIfExists: true });
- wsedit.createFile(filePathHpp, { ignoreIfExists: true });
- vscode.workspace.applyEdit(wsedit);
- getTemplate( name, filePathCpp, filePathHpp );
- await getHeadercpp( command, filePathCpp );
- await getHeaderhpp( command, filePathHpp );
- }
- }
- /*
- export async function createClass() {
- let name = await vscode.window.showInputBox({
- prompt: "Enter your Class Name",
- placeHolder: "ClassName",
- validateInput: (text: string): string | undefined => {
- if (!text){
- return 'You must enter a name';
- } else {
- return undefined;
- }
- }
- });
- let value1: string | undefined;
- let value2: string | undefined;
- let value3: string | undefined;
- let valueArray = [];
- let typeArray = [];
- for ( ; value1 !== 'exit' || !value1; )
- {
- value1 = await vscode.window.showInputBox({
- prompt: "Enter your Type Name, (Press 'exit' for leave.)",
- placeHolder: "Type",
- validateInput: (text: string): string | undefined => {
- if (!text){
- return 'You must enter a Type or Press \'exit\' if finish';
- } else {
- return undefined;
- }
- }
- })
- if (value1 != 'exit')
- value2 = await vscode.window.showInputBox({
- prompt: "Enter your variable Name",
- placeHolder: "Variable Name",
- validateInput: (text: string): string | undefined => {
- if (!text){
- return 'You must enter a Variable';
- } else {
- return undefined;
- }
- }
- })
- if (value1 !== 'exit')
- {
- typeArray.push(value1?.toLowerCase());
- valueArray.push(value2?.toLowerCase());
- }
- }
- if (name !== undefined){
- name = name.charAt(0).toUpperCase() + name.slice(1).toLowerCase()
- const wsedit = new vscode.WorkspaceEdit();
- const wsPath = vscode.workspace.workspaceFolders![0].uri.fsPath;
- const filePathCpp = vscode.Uri.file(wsPath + '/' + name + '.Class' + '.cpp');
- const filePathHpp = vscode.Uri.file(wsPath + '/' + name + '.Class' + '.hpp');
- wsedit.createFile(filePathCpp, { ignoreIfExists: true });
- wsedit.createFile(filePathHpp, { ignoreIfExists: true });
- vscode.workspace.applyEdit(wsedit);
- getTemplateFull( name, filePathCpp, filePathHpp, valueArray, typeArray )
- }
- }
- */
|