Skip to main content

contract_cli/
config.rs

1// Thin shim over finance-core so the CLI doesn't learn finance-core's layout.
2
3use std::path::PathBuf;
4
5use finance_core::paths::Paths;
6pub use finance_core::settings::Settings as Config;
7
8use crate::error::Result;
9
10fn paths() -> Result<Paths> {
11    Ok(Paths::resolve()?)
12}
13
14pub fn config_path() -> Result<PathBuf> {
15    Ok(paths()?.config_file())
16}
17
18pub fn state_path() -> Result<PathBuf> {
19    Ok(paths()?.data_dir)
20}
21
22pub fn db_path() -> Result<PathBuf> {
23    Ok(paths()?.db_file())
24}
25
26pub fn assets_path() -> Result<PathBuf> {
27    Ok(paths()?.assets_dir())
28}
29
30pub fn load() -> Result<Config> {
31    let p = paths()?;
32    Ok(Config::load(&p)?)
33}
34
35pub fn ensure_dirs() -> Result<()> {
36    let p = paths()?;
37    std::fs::create_dir_all(p.assets_dir())?;
38    Ok(())
39}