@@ -20,7 +20,10 @@ function handleBooleanFlags () {
2020 'conf' ,
2121 'once' ,
2222 'no-escape' ,
23- 'overwrite'
23+ 'overwrite' ,
24+ 'excludeReg' ,
25+ 'startLine' ,
26+ 'endLine' ,
2427 ] ;
2528
2629 return new Promise ( ( resolve , reject ) => {
@@ -73,15 +76,25 @@ const activate = (context) => {
7376 const disposable = vscode . commands . registerCommand (
7477 "code-replacer-vscode-plugin.entry" ,
7578 async function ( ) {
79+ if ( ! vscode . window . activeTextEditor || ! vscode . window . activeTextEditor . document ) {
80+ vscode . window . showErrorMessage ( "Jobs canceled. open the source file first." ) ;
81+ return ;
82+ }
83+
84+ const currentlyOpenTabfilePath =
85+ vscode . window . activeTextEditor . document . fileName ;
86+
87+ const currentlyOpenTabfileName = path . basename ( currentlyOpenTabfilePath ) ;
88+
7689 const codeReplacerPath = `${ __dirname } ${ path . sep } node_modules${
7790 path . sep
7891 } code-replacer${ path . sep } dist`;
7992 const binPath = path . resolve (
80- `${ codeReplacerPath } ${ path . sep } src ${ path . sep } index.js`
93+ `${ codeReplacerPath } ${ path . sep } index.js`
8194 ) ;
82- const envPath = path . resolve ( `${ codeReplacerPath } ${ path . sep } src ${ path . sep } ${ ".env" } ` ) ;
95+ const envPath = path . resolve ( `${ codeReplacerPath } ${ path . sep } ${ ".env" } ` ) ;
8396 const usageLogPath = path . resolve (
84- `${ codeReplacerPath } ${ path . sep } src ${ path . sep } usageLog.json`
97+ `${ codeReplacerPath } ${ path . sep } usageLog.json`
8598 ) ;
8699 const workspaceName = vscode . workspace . name ;
87100 const workspacePath = vscode . workspace . rootPath ;
@@ -91,13 +104,10 @@ const activate = (context) => {
91104 } ) ;
92105 const selectedCSV = await getQuickPick ( {
93106 items : csvFiles ,
94- placeHolder : "Select your csv file. " ,
107+ placeHolder : "Select your csv file or type esc to pass csv option " ,
95108 } ) ;
96109
97- const currentlyOpenTabfilePath =
98- vscode . window . activeTextEditor . document . fileName ;
99-
100- const currentlyOpenTabfileName = path . basename ( currentlyOpenTabfilePath ) ;
110+ vscode . window . showInformationMessage ( "csv option is passed." ) ;
101111
102112 const flags = {
103113 src : currentlyOpenTabfilePath ,
@@ -106,11 +116,32 @@ const activate = (context) => {
106116
107117 flags . template = await handleTemplate ( { usageLogPath } ) ;
108118
119+ if ( ! flags . template ) {
120+ vscode . window . showErrorMessage ( "Jobs canceled. template value is required argument." ) ;
121+ return ;
122+ } else if ( ! validateTemplate ( flags . template ) ) {
123+ vscode . window . showErrorMessage ( "Wrong template value. See README.md" ) ;
124+ return ;
125+ }
126+
109127 const booleanFlags = await handleBooleanFlags ( ) ;
128+
110129 for ( const booleanFlag of booleanFlags . values ( ) ) {
111130 flags [ booleanFlag ] = true ;
112131 }
113132
133+ if ( flags [ 'excludeReg' ] ) {
134+ flags [ 'excludeReg' ] = await getInput ( { placeHolder : "Enter excludeReg" } ) ;
135+ }
136+
137+ if ( flags [ 'startLine' ] ) {
138+ flags [ 'startLine' ] = await getInput ( { placeHolder : "Enter startLine" } ) ;
139+ }
140+
141+ if ( flags [ 'endLine' ] ) {
142+ flags [ 'endLine' ] = await getInput ( { placeHolder : "Enter endLine" } ) ;
143+ }
144+
114145 const terminal = vscode . window . activeTerminal
115146 ? vscode . window . activeTerminal
116147 : vscode . window . createTerminal ( ) ;
0 commit comments