@@ -78,6 +78,7 @@ pub struct Opts {
78
78
pub remove_previous_search : bool ,
79
79
80
80
/// CAUTION: Skip authentication checks, making all data publicly readable. Improves performance.
81
+
81
82
#[ clap( long, env = "ATOMIC_PUBLIC_MODE" ) ]
82
83
pub public_mode : bool ,
83
84
@@ -92,6 +93,18 @@ pub struct Opts {
92
93
/// How you want to trace what's going on with the server. Useful for monitoring performance and errors in production.
93
94
#[ clap( arg_enum, long, env = "ATOMIC_TRACING" , default_value = "stdout" ) ]
94
95
pub trace : Tracing ,
96
+
97
+ /// Add this if you want so send e-mails (e.g. on user registration)
98
+ #[ clap( long, env = "ATOMIC_SMTP_HOST" ) ]
99
+ pub smpt_host : Option < String > ,
100
+
101
+ /// Useful for debugging e-mails during development, or if your SMTP server has an unconventional port number.
102
+ #[ clap( long, env = "ATOMIC_SMTP_PORT" , default_value = "25" ) ]
103
+ pub smpt_port : u16 ,
104
+
105
+ /// If you want to parse options from a specific .env file. By default reads the `./.env` file.
106
+ #[ clap( long) ]
107
+ pub env_file : Option < PathBuf > ,
95
108
}
96
109
97
110
#[ derive( clap:: ArgEnum , Clone , Debug ) ]
@@ -198,7 +211,14 @@ pub fn read_opts() -> Opts {
198
211
dotenv ( ) . ok ( ) ;
199
212
200
213
// Parse CLI options, .env values, set defaults
201
- Opts :: parse ( )
214
+ let mut opts = Opts :: parse ( ) ;
215
+ if let Some ( env_path) = & opts. env_file {
216
+ dotenv:: from_path ( env_path)
217
+ . unwrap_or_else ( |_| panic ! ( "Env file not found: {} " , env_path. display( ) ) ) ;
218
+ // Parse the opts again so the CLI opts override the .env file
219
+ opts = Opts :: parse ( ) ;
220
+ }
221
+ opts
202
222
}
203
223
204
224
/// Creates the server config, reads .env values and sets defaults
0 commit comments