@@ -864,20 +864,35 @@ impl Config {
864
864
} ;
865
865
let mut loaded_args = CV :: Table ( HashMap :: new ( ) , Definition :: Cli ) ;
866
866
for arg in cli_args {
867
- // TODO: This should probably use a more narrow parser, reject
868
- // comments, blank lines, [headers], etc.
869
- let toml_v: toml:: Value = toml:: de:: from_str ( arg)
870
- . chain_err ( || format ! ( "failed to parse --config argument `{}`" , arg) ) ?;
871
- let toml_table = toml_v. as_table ( ) . unwrap ( ) ;
872
- if toml_table. len ( ) != 1 {
873
- bail ! (
874
- "--config argument `{}` expected exactly one key=value pair, got {} keys" ,
875
- arg,
876
- toml_table. len( )
877
- ) ;
878
- }
879
- let tmp_table = CV :: from_toml ( Definition :: Cli , toml_v)
880
- . chain_err ( || format ! ( "failed to convert --config argument `{}`" , arg) ) ?;
867
+ let arg_as_path = self . cwd . join ( arg) ;
868
+ let tmp_table = if !arg. is_empty ( ) && arg_as_path. exists ( ) {
869
+ // --config path_to_file
870
+ let str_path = arg_as_path
871
+ . to_str ( )
872
+ . ok_or_else ( || {
873
+ anyhow:: format_err!( "config path {:?} is not utf-8" , arg_as_path)
874
+ } ) ?
875
+ . to_string ( ) ;
876
+ let mut map = HashMap :: new ( ) ;
877
+ let value = CV :: String ( str_path, Definition :: Cli ) ;
878
+ map. insert ( "include" . to_string ( ) , value) ;
879
+ CV :: Table ( map, Definition :: Cli )
880
+ } else {
881
+ // TODO: This should probably use a more narrow parser, reject
882
+ // comments, blank lines, [headers], etc.
883
+ let toml_v: toml:: Value = toml:: de:: from_str ( arg)
884
+ . chain_err ( || format ! ( "failed to parse --config argument `{}`" , arg) ) ?;
885
+ let toml_table = toml_v. as_table ( ) . unwrap ( ) ;
886
+ if toml_table. len ( ) != 1 {
887
+ bail ! (
888
+ "--config argument `{}` expected exactly one key=value pair, got {} keys" ,
889
+ arg,
890
+ toml_table. len( )
891
+ ) ;
892
+ }
893
+ CV :: from_toml ( Definition :: Cli , toml_v)
894
+ . chain_err ( || format ! ( "failed to convert --config argument `{}`" , arg) ) ?
895
+ } ;
881
896
let mut seen = HashSet :: new ( ) ;
882
897
let tmp_table = self
883
898
. load_includes ( tmp_table, & mut seen)
0 commit comments