@@ -78,6 +78,7 @@ pub struct Opts {
7878 pub remove_previous_search : bool ,
7979
8080 /// CAUTION: Skip authentication checks, making all data publicly readable. Improves performance.
81+
8182 #[ clap( long, env = "ATOMIC_PUBLIC_MODE" ) ]
8283 pub public_mode : bool ,
8384
@@ -92,6 +93,18 @@ pub struct Opts {
9293 /// How you want to trace what's going on with the server. Useful for monitoring performance and errors in production.
9394 #[ clap( arg_enum, long, env = "ATOMIC_TRACING" , default_value = "stdout" ) ]
9495 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 > ,
95108}
96109
97110#[ derive( clap:: ArgEnum , Clone , Debug ) ]
@@ -198,7 +211,14 @@ pub fn read_opts() -> Opts {
198211 dotenv ( ) . ok ( ) ;
199212
200213 // 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
202222}
203223
204224/// Creates the server config, reads .env values and sets defaults
0 commit comments