File tree Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change 1
1
#![ deny( rust_2018_idioms) ]
2
2
#![ deny( clippy:: all) ]
3
3
4
- use std:: error:: Error ;
4
+ use std:: { env :: VarError , error:: Error } ;
5
5
6
6
use clap:: { crate_version, Arg , Command } ;
7
7
@@ -64,10 +64,12 @@ fn main() -> Result<(), Box<dyn Error>> {
64
64
)
65
65
. get_matches ( ) ;
66
66
67
- let environment: Environment = serde_json:: from_value ( serde_json:: Value :: String (
68
- std:: env:: var ( "ENV" ) . expect ( "Valid environment variable" ) ,
69
- ) )
70
- . expect ( "Valid Environment - development or production" ) ;
67
+ let environment: Environment = match std:: env:: var ( "ENV" ) {
68
+ Ok ( string) => serde_json:: from_value ( serde_json:: Value :: String ( string) )
69
+ . expect ( "Valid Environment - development or production" ) ,
70
+ Err ( VarError :: NotPresent ) => Environment :: default ( ) ,
71
+ Err ( err) => panic ! ( "Invalid `ENV`: {err}" ) ,
72
+ } ;
71
73
72
74
let config_file = cli. value_of ( "config" ) ;
73
75
let config = configuration ( environment, config_file) . expect ( "failed to parse configuration" ) ;
You can’t perform that action at this time.
0 commit comments