| 55 | } |
| 56 | |
| 57 | pub fn get_pattern(config_path: Option<PathBuf>) -> Result<CommitPattern> { |
| 58 | let selected_config_path = select_custom_config_path(config_path)?; |
| 59 | if selected_config_path.exists() { |
| 60 | let file = File::open(&selected_config_path).context(format!( |
| 61 | "Could not open config file: {}", |
| 62 | selected_config_path.display() |
| 63 | ))?; |
| 64 | let reader = std::io::BufReader::new(file); |
| 65 | Ok(serde_json::from_reader(reader).context(format!( |
| 66 | "Could not parse config file: {}", |
| 67 | selected_config_path.display() |
| 68 | ))?) |
| 69 | } else { |
| 70 | Ok(CommitPattern::default()) |
| 71 | } |
| 72 | } |