File tree Expand file tree Collapse file tree 2 files changed +14
-8
lines changed Expand file tree Collapse file tree 2 files changed +14
-8
lines changed Original file line number Diff line number Diff line change @@ -33,13 +33,17 @@ pub struct Configuration {
33
33
}
34
34
35
35
impl Configuration {
36
- pub fn get ( filename : & str ) -> Result < Configuration , String > {
37
- let toml_content = match fs:: read_to_string ( filename) {
38
- Ok ( v) => v,
39
- Err ( err) => return Err ( format ! ( "read config file error: {}" , err) . to_string ( ) ) ,
40
- } ;
36
+ pub fn get ( filenames : Vec < String > ) -> Result < Configuration , String > {
37
+ let mut content: String = String :: new ( ) ;
38
+
39
+ for file_name in & filenames {
40
+ content. push_str ( & match fs:: read_to_string ( file_name) {
41
+ Ok ( v) => v,
42
+ Err ( err) => return Err ( format ! ( "read config file error: {}" , err) . to_string ( ) ) ,
43
+ } ) ;
44
+ }
41
45
42
- let config: Configuration = match toml:: from_str ( & toml_content ) {
46
+ let config: Configuration = match toml:: from_str ( & content ) {
43
47
Ok ( v) => v,
44
48
Err ( err) => return Err ( format ! ( "parse config file error: {}" , err) ) ,
45
49
} ;
Original file line number Diff line number Diff line change @@ -29,13 +29,15 @@ fn main() {
29
29
. short ( "c" )
30
30
. long ( "config" )
31
31
. value_name ( "FILE" )
32
+ . multiple ( true )
33
+ . number_of_values ( 1 )
32
34
. help ( "Path to configuration file" )
33
35
. takes_value ( true ) ,
34
36
)
35
37
. get_matches ( ) ;
36
38
37
- let config_file = matches. value_of_lossy ( "config" ) . unwrap ( ) ;
38
- let config = config:: Configuration :: get ( & config_file ) . expect ( "read configuration error" ) ;
39
+ let config_files = matches. values_of_lossy ( "config" ) . unwrap_or ( vec ! [ ] ) ;
40
+ let config = config:: Configuration :: get ( config_files ) . expect ( "read configuration error" ) ;
39
41
let log_level =
40
42
log:: Level :: from_str ( & config. udp_bridge . log_level ) . expect ( "parse log_level error" ) ;
41
43
You can’t perform that action at this time.
0 commit comments