@@ -319,14 +319,18 @@ impl WalletManager {
319319 "Cancel" ,
320320 ] ;
321321
322- let selection = Select :: new ( )
323- . with_prompt ( "What would you like to do?" )
324- . items ( & options)
325- . default ( 0 )
326- . interact ( )
327- . map_err ( |e| DigstoreError :: ConfigurationError {
328- reason : format ! ( "Failed to get user input: {}" , e) ,
329- } ) ?;
322+ let selection = if crate :: cli:: context:: CliContext :: is_non_interactive ( ) {
323+ 0 // Default to "Generate new mnemonic" in non-interactive mode
324+ } else {
325+ Select :: new ( )
326+ . with_prompt ( "What would you like to do?" )
327+ . items ( & options)
328+ . default ( 0 )
329+ . interact ( )
330+ . map_err ( |e| DigstoreError :: ConfigurationError {
331+ reason : format ! ( "Failed to get user input: {}" , e) ,
332+ } ) ?
333+ } ;
330334
331335 match selection {
332336 0 => self . generate_new_wallet_with_context ( is_first_time) ,
@@ -413,13 +417,17 @@ impl WalletManager {
413417 println ! ( ) ;
414418
415419 // Confirm user has written down the mnemonic
416- let confirmed = Confirm :: new ( )
417- . with_prompt ( "Have you securely written down your mnemonic phrase?" )
418- . default ( false )
419- . interact ( )
420- . map_err ( |e| DigstoreError :: ConfigurationError {
421- reason : format ! ( "Failed to get user confirmation: {}" , e) ,
422- } ) ?;
420+ let confirmed = if crate :: cli:: context:: CliContext :: is_non_interactive ( ) {
421+ true // Auto-confirm in non-interactive mode
422+ } else {
423+ Confirm :: new ( )
424+ . with_prompt ( "Have you securely written down your mnemonic phrase?" )
425+ . default ( false )
426+ . interact ( )
427+ . map_err ( |e| DigstoreError :: ConfigurationError {
428+ reason : format ! ( "Failed to get user confirmation: {}" , e) ,
429+ } ) ?
430+ } ;
423431
424432 if !confirmed {
425433 println ! ( ) ;
@@ -483,12 +491,18 @@ impl WalletManager {
483491 println ! ( "Please enter your mnemonic phrase:" ) ;
484492 println ! ( ) ;
485493
486- let mnemonic: String = Input :: new ( )
487- . with_prompt ( "Mnemonic phrase" )
488- . interact_text ( )
489- . map_err ( |e| DigstoreError :: ConfigurationError {
490- reason : format ! ( "Failed to get mnemonic input: {}" , e) ,
491- } ) ?;
494+ let mnemonic: String = if crate :: cli:: context:: CliContext :: is_non_interactive ( ) {
495+ return Err ( DigstoreError :: ConfigurationError {
496+ reason : "Cannot import wallet in non-interactive mode. Use --auto-import-mnemonic flag instead." . to_string ( ) ,
497+ } ) ;
498+ } else {
499+ Input :: new ( )
500+ . with_prompt ( "Mnemonic phrase" )
501+ . interact_text ( )
502+ . map_err ( |e| DigstoreError :: ConfigurationError {
503+ reason : format ! ( "Failed to get mnemonic input: {}" , e) ,
504+ } ) ?
505+ } ;
492506
493507 let rt = tokio:: runtime:: Runtime :: new ( ) . map_err ( |e| DigstoreError :: ConfigurationError {
494508 reason : format ! ( "Failed to create tokio runtime: {}" , e) ,
@@ -517,14 +531,18 @@ impl WalletManager {
517531 "Cancel" ,
518532 ] ;
519533
520- let selection = Select :: new ( )
521- . with_prompt ( "What would you like to do?" )
522- . items ( & options)
523- . default ( 0 )
524- . interact ( )
525- . map_err ( |e| DigstoreError :: ConfigurationError {
526- reason : format ! ( "Failed to get user input: {}" , e) ,
527- } ) ?;
534+ let selection = if crate :: cli:: context:: CliContext :: is_non_interactive ( ) {
535+ 1 // Default to "Delete and create new wallet" in non-interactive mode
536+ } else {
537+ Select :: new ( )
538+ . with_prompt ( "What would you like to do?" )
539+ . items ( & options)
540+ . default ( 0 )
541+ . interact ( )
542+ . map_err ( |e| DigstoreError :: ConfigurationError {
543+ reason : format ! ( "Failed to get user input: {}" , e) ,
544+ } ) ?
545+ } ;
528546
529547 match selection {
530548 0 => {
@@ -533,13 +551,17 @@ impl WalletManager {
533551 } ,
534552 1 => {
535553 // Confirm deletion
536- let confirmed = Confirm :: new ( )
537- . with_prompt ( "This will permanently delete your current wallet. Are you sure?" )
538- . default ( false )
539- . interact ( )
540- . map_err ( |e| DigstoreError :: ConfigurationError {
541- reason : format ! ( "Failed to get user confirmation: {}" , e) ,
542- } ) ?;
554+ let confirmed = if crate :: cli:: context:: CliContext :: should_auto_accept ( ) {
555+ true // Auto-confirm in non-interactive or yes mode
556+ } else {
557+ Confirm :: new ( )
558+ . with_prompt ( "This will permanently delete your current wallet. Are you sure?" )
559+ . default ( false )
560+ . interact ( )
561+ . map_err ( |e| DigstoreError :: ConfigurationError {
562+ reason : format ! ( "Failed to get user confirmation: {}" , e) ,
563+ } ) ?
564+ } ;
543565
544566 if confirmed {
545567 // Try to delete the wallet using dig-wallet API
0 commit comments