File tree 2 files changed +15
-10
lines changed
2 files changed +15
-10
lines changed Original file line number Diff line number Diff line change @@ -276,8 +276,12 @@ fn default_convert_dos_to_unix() -> bool {
276
276
}
277
277
278
278
impl Config {
279
- pub fn from_dir ( path : & PathBuf ) -> Result < Self > {
280
- let filename = path. join ( "mujmap.toml" ) ;
279
+ pub fn from_path ( path : & PathBuf ) -> Result < Self > {
280
+ let filename = if path. is_dir ( ) {
281
+ path. join ( "mujmap.toml" )
282
+ } else {
283
+ path. clone ( )
284
+ } ;
281
285
282
286
let contents = fs:: read_to_string ( & filename) . context ( ReadConfigFileSnafu {
283
287
filename : filename. clone ( ) ,
@@ -287,11 +291,13 @@ impl Config {
287
291
} ) ?;
288
292
289
293
// In directory mode, if paths aren't offered then we use the config dir itself.
290
- if config. mail_dir . is_none ( ) {
291
- config. mail_dir = Some ( path. clone ( ) ) ;
292
- }
293
- if config. state_dir . is_none ( ) {
294
- config. state_dir = Some ( path. clone ( ) ) ;
294
+ if path. is_dir ( ) {
295
+ if config. mail_dir . is_none ( ) {
296
+ config. mail_dir = Some ( path. clone ( ) ) ;
297
+ }
298
+ if config. state_dir . is_none ( ) {
299
+ config. state_dir = Some ( path. clone ( ) ) ;
300
+ }
295
301
}
296
302
297
303
// Perform final validation.
Original file line number Diff line number Diff line change @@ -61,9 +61,8 @@ fn try_main(stdout: &mut StandardStream) -> Result<(), Error> {
61
61
. to_owned ( ) ;
62
62
63
63
// Determine working directory and load all data files.
64
- let config_dir = args. path . clone ( ) . unwrap_or_else ( || PathBuf :: from ( "." ) ) ;
65
-
66
- let config = Config :: from_dir ( & config_dir) . context ( OpenConfigFileSnafu { } ) ?;
64
+ let config_path = args. path . clone ( ) . unwrap_or_else ( || PathBuf :: from ( "." ) ) ;
65
+ let config = Config :: from_path ( & config_path) . context ( OpenConfigFileSnafu { } ) ?;
67
66
debug ! ( "Using config: {:?}" , config) ;
68
67
69
68
match args. command {
You can’t perform that action at this time.
0 commit comments