(home_path: CliTomlPath)
| 624 | } |
| 625 | |
| 626 | pub fn load(home_path: CliTomlPath) -> anyhow::Result<Self> { |
| 627 | let home = Self::parse_config(home_path.as_ref()) |
| 628 | .with_context(|| format!("config file {} is invalid", home_path.display()))?; |
| 629 | Ok(match home { |
| 630 | Some((doc, home)) => Self { home, home_path, doc }, |
| 631 | None => { |
| 632 | let config = Self { |
| 633 | home: RawConfig::new_with_localhost(), |
| 634 | home_path, |
| 635 | doc: Default::default(), |
| 636 | }; |
| 637 | config.save(); |
| 638 | config |
| 639 | } |
| 640 | }) |
| 641 | } |
| 642 | |
| 643 | #[doc(hidden)] |
| 644 | /// Used in tests. |
no test coverage detected