@@ -5,7 +5,10 @@ use crate::{
55 db:: { DatabaseBackend , DatabaseClient , EraseOptions } ,
66 } ,
77} ;
8- use std:: { io:: stdin, process:: exit} ;
8+ use std:: {
9+ io:: { Write , stdin, stdout} ,
10+ process:: exit,
11+ } ;
912use tracing:: { debug, error, info} ;
1013
1114#[ allow( clippy:: cognitive_complexity) ]
@@ -46,16 +49,7 @@ pub async fn main(cmd: DatabaseCommand, config: &Config) {
4649 info ! ( "Connected to the database" ) ;
4750 confirm_erase ( & config. database . name ( ) , & config. database . host ( ) ) ;
4851
49- let opts = if content_only && keep_devices {
50- EraseOptions :: ContentOnly { keep_devices : true }
51- } else if content_only {
52- EraseOptions :: ContentOnly {
53- keep_devices : false ,
54- }
55- } else {
56- EraseOptions :: Everything
57- } ;
58-
52+ let opts = EraseOptions :: new ( content_only, keep_devices) ;
5953 match client. erase ( opts) . await {
6054 Ok ( ( ) ) => info ! ( "Success!" ) ,
6155 Err ( why) => error ! ( "Failed to erase database: {why}" ) ,
@@ -77,6 +71,8 @@ fn confirm_erase(database_name: &str, host: &str) {
7771 println ! ( ) ;
7872 print ! ( "Type '{KEY}' to confirm: " ) ;
7973
74+ let _ = stdout ( ) . flush ( ) ;
75+
8076 let mut buf = String :: new ( ) ;
8177 stdin ( ) . read_line ( & mut buf) . unwrap_or_default ( ) ;
8278
0 commit comments