@@ -59,35 +59,45 @@ fn get_config_from_input() -> Result<Config> {
5959 }
6060 }
6161
62- print ! ( "Enter database host: " ) ;
63- io:: stdout ( ) . flush ( ) ?;
64- let mut db_host = String :: new ( ) ;
65- io:: stdin ( ) . read_line ( & mut db_host) ?;
66- config = config. set_db_host ( db_host. trim ( ) ) ;
62+ cfg_if:: cfg_if! {
63+ if #[ cfg( any(
64+ feature = "mysql" ,
65+ feature = "mssql" ,
66+ feature = "postgresql" ,
67+ ) ) ] {
68+ print!( "Enter database host: " ) ;
69+ io:: stdout( ) . flush( ) ?;
70+ let mut db_host = String :: new( ) ;
71+ io:: stdin( ) . read_line( & mut db_host) ?;
72+ config = config. set_db_host( db_host. trim( ) ) ;
6773
68- print ! ( "Enter database port: " ) ;
69- io:: stdout ( ) . flush ( ) ?;
70- let mut db_port = String :: new ( ) ;
71- io:: stdin ( ) . read_line ( & mut db_port) ?;
72- config = config. set_db_port ( db_port. trim ( ) ) ;
74+ print!( "Enter database port: " ) ;
75+ io:: stdout( ) . flush( ) ?;
76+ let mut db_port = String :: new( ) ;
77+ io:: stdin( ) . read_line( & mut db_port) ?;
78+ config = config. set_db_port( db_port. trim( ) ) ;
7379
74- print ! ( "Enter database username: " ) ;
75- io:: stdout ( ) . flush ( ) ?;
76- let mut db_user = String :: new ( ) ;
77- io:: stdin ( ) . read_line ( & mut db_user) ?;
78- config = config. set_db_user ( db_user. trim ( ) ) ;
80+ print!( "Enter database username: " ) ;
81+ io:: stdout( ) . flush( ) ?;
82+ let mut db_user = String :: new( ) ;
83+ io:: stdin( ) . read_line( & mut db_user) ?;
84+ config = config. set_db_user( db_user. trim( ) ) ;
7985
80- print ! ( "Enter database password: " ) ;
81- io:: stdout ( ) . flush ( ) ?;
82- let mut db_pass = String :: new ( ) ;
83- io:: stdin ( ) . read_line ( & mut db_pass) ?;
84- config = config. set_db_pass ( db_pass. trim ( ) ) ;
86+ print!( "Enter database password: " ) ;
87+ io:: stdout( ) . flush( ) ?;
88+ let mut db_pass = String :: new( ) ;
89+ io:: stdin( ) . read_line( & mut db_pass) ?;
90+ config = config. set_db_pass( db_pass. trim( ) ) ;
8591
86- print ! ( "Enter database name: " ) ;
87- io:: stdout ( ) . flush ( ) ?;
88- let mut db_name = String :: new ( ) ;
89- io:: stdin ( ) . read_line ( & mut db_name) ?;
90- config = config. set_db_name ( db_name. trim ( ) ) ;
92+ print!( "Enter database name: " ) ;
93+ io:: stdout( ) . flush( ) ?;
94+ let mut db_name = String :: new( ) ;
95+ io:: stdin( ) . read_line( & mut db_name) ?;
96+ config = config. set_db_name( db_name. trim( ) ) ;
9197
92- Ok ( config)
98+ Ok ( config)
99+ } else {
100+ Ok ( config)
101+ }
102+ }
93103}
0 commit comments