File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -24,13 +24,18 @@ impl Config {
2424 return Ok ( Self :: default ( ) ) ;
2525 } ;
2626 let csmrc_path = home. join ( ".csmrc" ) ;
27- let Ok ( csmrc_data) = std:: fs:: read_to_string ( csmrc_path) else {
28- debug ! ( "No .csmrc found, using defaults" ) ;
29- return Ok ( Config :: default ( ) ) ;
30- } ;
31- let config =
32- serde_yaml_ng:: from_str ( & csmrc_data) . map_err ( |e| Error :: new ( ErrorKind :: InvalidData , e) ) ;
33- debug ! ( "config: {:?}" , config) ;
34- config
27+ match std:: fs:: read_to_string ( csmrc_path) {
28+ Err ( e) if e. kind ( ) == ErrorKind :: NotFound => {
29+ debug ! ( "No .csmrc found, using defaults" ) ;
30+ Ok ( Config :: default ( ) )
31+ }
32+ Err ( e) => Err ( e) ,
33+ Ok ( csmrc_data) => {
34+ let config = serde_yaml_ng:: from_str ( & csmrc_data)
35+ . map_err ( |e| Error :: new ( ErrorKind :: InvalidData , e) ) ;
36+ debug ! ( "config: {:?}" , config) ;
37+ config
38+ }
39+ }
3540 }
3641}
Original file line number Diff line number Diff line change @@ -93,7 +93,7 @@ pub fn run(config: Config, subcommand: Subcommand) -> ExitCode {
9393 Subcommand :: Create ( args) => {
9494 let Some ( env_name) = determine_env_name ( args) else {
9595 error ! ( "No environment name could be determined. You can specify one with --name" ) ;
96- return ExitCode :: FAILURE
96+ return ExitCode :: FAILURE ;
9797 } ;
9898 println ! ( "env: {}" , env_name) ;
9999 }
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ use clap::{Parser, Subcommand};
77use log:: { LevelFilter , debug, error, warn} ;
88use std:: fs:: File ;
99use std:: io:: Write ;
10- use std:: path:: PathBuf ;
10+ use std:: path:: Path ;
1111use std:: process:: ExitCode ;
1212
1313#[ derive( Parser , Debug ) ]
@@ -54,7 +54,11 @@ fn main() -> ExitCode {
5454
5555 if let Err ( e) = create_mambarc ( & home) {
5656 let attempted_path = home. join ( ".mambarc" ) ;
57- warn ! ( "Could not create {}, but continuing: {}" , attempted_path. display( ) , e) ;
57+ warn ! (
58+ "Could not create {}, but continuing: {}" ,
59+ attempted_path. display( ) ,
60+ e
61+ ) ;
5862 }
5963
6064 let config = match csmrc:: Config :: from_csmrc ( ) {
@@ -72,7 +76,7 @@ fn main() -> ExitCode {
7276
7377/// Create a ~/.mambarc (%UserProfile%\.mambarc on Windows) if it does not
7478/// exist.
75- fn create_mambarc ( home : & PathBuf ) -> std:: io:: Result < ( ) > {
79+ fn create_mambarc ( home : & Path ) -> std:: io:: Result < ( ) > {
7680 let mambarc = include_str ! ( "../templates/mambarc" ) ;
7781 let mambarc_path = home. join ( ".mambarc" ) ;
7882 match File :: create_new ( & mambarc_path) {
Original file line number Diff line number Diff line change @@ -2,5 +2,8 @@ use std::env;
22use std:: path:: PathBuf ;
33
44pub fn homedir ( ) -> Option < PathBuf > {
5- env:: var ( "HOME" ) . ok ( ) . or_else ( || env:: var ( "USERPROFILE" ) . ok ( ) ) . map ( PathBuf :: from)
5+ env:: var ( "HOME" )
6+ . ok ( )
7+ . or_else ( || env:: var ( "USERPROFILE" ) . ok ( ) )
8+ . map ( PathBuf :: from)
69}
You can’t perform that action at this time.
0 commit comments