@@ -174,6 +174,22 @@ const getWalletFileChoices = async () => {
174
174
} ;
175
175
176
176
177
+ // Prompts
178
+
179
+ const promptWalletPath = async ( ) => {
180
+ console . log ( '\u001B[33m%s\u001B[0m' , 'In order to unzip and copy the Wallet file, please ensure that you have file access permissions. \n' ) ;
181
+
182
+ return await input (
183
+ {
184
+ // TODO: Cannot use tab to autocomplete, cannot use ~ for $HOME
185
+ message : 'Please enter the path of your Oracle Wallet:' ,
186
+ validate ( input ) {
187
+ return checkIfDirectoryOrZip ( input ) ;
188
+ }
189
+ }
190
+ ) ;
191
+ }
192
+
177
193
// Here we promisify the exec function from child_process to use it with async/await
178
194
const execAsync = promisify ( exec ) ;
179
195
export default class Generate extends Command {
@@ -300,6 +316,12 @@ export default class Generate extends Command {
300
316
301
317
// TODO: Validate and use wallet path
302
318
const walletPathDirectory = flags [ 'wallet-path' ] ? flags [ 'wallet-path' ] : '' ;
319
+ let walletPathValidationResult = undefined ;
320
+
321
+ if ( walletPathDirectory !== '' ) {
322
+ walletPathValidationResult = checkIfDirectoryOrZip ( walletPathDirectory ) ;
323
+ }
324
+
303
325
304
326
// Ask the user for the application name.
305
327
const appName = name === '' ? await input (
@@ -438,20 +460,18 @@ export default class Generate extends Command {
438
460
connectionString : generateConnectionString ( protocol , hostname , port , serviceValue )
439
461
} ;
440
462
} else {
441
- let walletPath ;
442
-
443
- console . log ( '\u001B[33m%s\u001B[0m' , 'In order to unzip and copy the Wallet file, please ensure that the read permissions have been given to the terminal. \n' ) ;
463
+ let walletPath = '' ;
444
464
445
- walletPath = await input (
446
- {
447
- // TODO: Cannot use tab to autocomplete, cannot use ~ for $HOME
448
- message : 'Please enter your Cloud Wallet Path:' ,
449
- validate ( input ) {
450
- return checkIfDirectoryOrZip ( input ) ;
451
- }
465
+ if ( walletPathValidationResult === true ) {
466
+ walletPath = walletPathDirectory ;
467
+ }
468
+ else {
469
+ if ( walletPathValidationResult !== undefined ) {
470
+ console . error ( '\u001B[31m%s\u001B[0m' , walletPathValidationResult ) ;
452
471
}
453
- ) ;
454
472
473
+ walletPath = await promptWalletPath ( ) ;
474
+ }
455
475
// walletPath = createWalletDirectory( walletPath );
456
476
walletPath = path . resolve ( untildify ( walletPath ) ) ;
457
477
walletDirectory = path . dirname ( walletPath ) ;
0 commit comments