@@ -23,9 +23,10 @@ export class PDKFeature implements IFeature {
2323 ) ;
2424 logger . debug ( 'Registered ' + PDKCommandStrings . PdkNewModuleCommandId + ' command' ) ;
2525
26+ // commands that require no user input
2627 [
27- { id : 'puppet .pdkValidate' , request : 'pdk validate' , type : 'validate' } ,
28- { id : 'puppet .pdkTestUnit' , request : 'pdk test unit' , type : 'test' } ,
28+ { id : 'extension .pdkValidate' , request : 'pdk validate' , type : 'validate' } ,
29+ { id : 'extension .pdkTestUnit' , request : 'pdk test unit' , type : 'test' } ,
2930 ] . forEach ( ( command ) => {
3031 context . subscriptions . push (
3132 vscode . commands . registerCommand ( command . id , ( ) => {
@@ -39,31 +40,43 @@ export class PDKFeature implements IFeature {
3940 logger . debug ( `Registered ${ command . id } command` ) ;
4041 } ) ;
4142
42- context . subscriptions . push (
43- vscode . commands . registerCommand ( PDKCommandStrings . PdkNewClassCommandId , ( ) => {
44- this . pdkNewClassCommand ( ) ;
45- } ) ,
46- ) ;
47- logger . debug ( 'Registered ' + PDKCommandStrings . PdkNewClassCommandId + ' command' ) ;
48- context . subscriptions . push (
49- vscode . commands . registerCommand ( PDKCommandStrings . PdkNewTaskCommandId , ( ) => {
50- this . pdkNewTaskCommand ( ) ;
51- } ) ,
52- ) ;
53- logger . debug ( 'Registered ' + PDKCommandStrings . PdkNewTaskCommandId + ' command' ) ;
54- context . subscriptions . push (
55- vscode . commands . registerCommand ( PDKCommandStrings . PdkNewDefinedTypeCommandId , ( ) => {
56- this . pdkNewDefinedTypeCommand ( ) ;
57- } ) ,
58- ) ;
59- logger . debug ( 'Registered ' + PDKCommandStrings . PdkNewTaskCommandId + ' command' ) ;
43+ // commands that require user input
44+ [
45+ { id : 'extension.pdkNewClass' , request : 'pdk new class' , type : 'Puppet class' } ,
46+ { id : 'extension.pdkNewTask' , request : 'pdk new task' , type : 'Bolt task' } ,
47+ { id : 'extension.pdkNewDefinedType' , request : 'pdk new defined_type' , type : 'Puppet defined_type' } ,
48+ ] . forEach ( ( command ) => {
49+ context . subscriptions . push (
50+ vscode . commands . registerCommand ( command . id , ( ) => {
51+ const nameOpts : vscode . QuickPickOptions = {
52+ placeHolder : `Enter a name for the new ${ command . type } ` ,
53+ matchOnDescription : true ,
54+ matchOnDetail : true ,
55+ } ;
56+
57+ vscode . window . showInputBox ( nameOpts ) . then ( ( name ) => {
58+ if ( name === undefined ) {
59+ vscode . window . showWarningMessage ( `No ${ command . type } value specifed. Exiting.` ) ;
60+ return ;
61+ }
62+ const request = `${ command . request } ${ name } ` ;
63+ this . terminal . sendText ( request ) ;
64+ this . terminal . show ( ) ;
65+ if ( reporter ) {
66+ reporter . sendTelemetryEvent ( command . id ) ;
67+ }
68+ } ) ;
69+ } ) ,
70+ ) ;
71+ logger . debug ( `Registered ${ command . id } command` ) ;
72+ } ) ;
6073 }
6174
62- public dispose ( ) : any {
75+ public dispose ( ) : void {
6376 this . terminal . dispose ( ) ;
6477 }
6578
66- private pdkNewModuleCommand ( ) {
79+ private pdkNewModuleCommand ( ) : void {
6780 const nameOpts : vscode . QuickPickOptions = {
6881 placeHolder : 'Enter a name for the new Puppet module' ,
6982 matchOnDescription : true ,
@@ -90,61 +103,4 @@ export class PDKFeature implements IFeature {
90103 } ) ;
91104 } ) ;
92105 }
93-
94- private pdkNewClassCommand ( ) {
95- const nameOpts : vscode . QuickPickOptions = {
96- placeHolder : 'Enter a name for the new Puppet class' ,
97- matchOnDescription : true ,
98- matchOnDetail : true ,
99- } ;
100- vscode . window . showInputBox ( nameOpts ) . then ( ( className ) => {
101- if ( className === undefined ) {
102- vscode . window . showWarningMessage ( 'No class name specifed. Exiting.' ) ;
103- return ;
104- }
105- this . terminal . sendText ( `pdk new class ${ className } ` ) ;
106- this . terminal . show ( ) ;
107- if ( reporter ) {
108- reporter . sendTelemetryEvent ( PDKCommandStrings . PdkNewClassCommandId ) ;
109- }
110- } ) ;
111- }
112-
113- private pdkNewTaskCommand ( ) {
114- const nameOpts : vscode . QuickPickOptions = {
115- placeHolder : 'Enter a name for the new Puppet Task' ,
116- matchOnDescription : true ,
117- matchOnDetail : true ,
118- } ;
119- vscode . window . showInputBox ( nameOpts ) . then ( ( taskName ) => {
120- if ( taskName === undefined ) {
121- vscode . window . showWarningMessage ( 'No task name specifed. Exiting.' ) ;
122- return ;
123- }
124- this . terminal . sendText ( `pdk new task ${ taskName } ` ) ;
125- this . terminal . show ( ) ;
126- if ( reporter ) {
127- reporter . sendTelemetryEvent ( PDKCommandStrings . PdkNewTaskCommandId ) ;
128- }
129- } ) ;
130- }
131-
132- private pdkNewDefinedTypeCommand ( ) {
133- const nameOpts : vscode . QuickPickOptions = {
134- placeHolder : 'Enter a name for the new Puppet defined type' ,
135- matchOnDescription : true ,
136- matchOnDetail : true ,
137- } ;
138- vscode . window . showInputBox ( nameOpts ) . then ( ( typeName ) => {
139- if ( typeName === undefined ) {
140- vscode . window . showWarningMessage ( 'No defined type name specifed. Exiting.' ) ;
141- return ;
142- }
143- this . terminal . sendText ( `pdk new defined_type ${ typeName } ` ) ;
144- this . terminal . show ( ) ;
145- if ( reporter ) {
146- reporter . sendTelemetryEvent ( PDKCommandStrings . PdkNewDefinedTypeCommandId ) ;
147- }
148- } ) ;
149- }
150106}
0 commit comments