mirror of
				https://github.com/hannobraun/Fornjot
				synced 2025-11-03 21:57:22 +00:00 
			
		
		
		
	Make default_model optional
				
					
				
			This commit is contained in:
		
							parent
							
								
									a9ce688a2c
								
							
						
					
					
						commit
						7a6d8e2e68
					
				@ -10,7 +10,7 @@ use serde::Deserialize;
 | 
			
		||||
#[derive(Debug, Deserialize)]
 | 
			
		||||
pub struct Config {
 | 
			
		||||
    pub default_path: Option<PathBuf>,
 | 
			
		||||
    pub default_model: PathBuf,
 | 
			
		||||
    pub default_model: Option<PathBuf>,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
impl Config {
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										12
									
								
								src/main.rs
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								src/main.rs
									
									
									
									
									
								
							@ -56,7 +56,17 @@ fn main() -> anyhow::Result<()> {
 | 
			
		||||
    let config = Config::load()?;
 | 
			
		||||
 | 
			
		||||
    let mut path = config.default_path.unwrap_or_else(|| PathBuf::from(""));
 | 
			
		||||
    path.push(args.model.unwrap_or(config.default_model));
 | 
			
		||||
    match args.model.or(config.default_model) {
 | 
			
		||||
        Some(model) => {
 | 
			
		||||
            path.push(model);
 | 
			
		||||
        }
 | 
			
		||||
        None => {
 | 
			
		||||
            anyhow::bail!(
 | 
			
		||||
                "No model specified, and no default model configured.\n\
 | 
			
		||||
                Specify a model by passing `--model path/to/model`."
 | 
			
		||||
            );
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    let model = Model::from_path(path)?;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user