1use anyhow::{Context, Result};
2use serde::{Deserialize, Serialize};
3use std::path::PathBuf;
4
5const APP_NAME: &str = "vdev";
6const FILE_STEM: &str = "config";
7
8#[derive(Serialize, Deserialize, Clone, Debug, Default)]
9pub struct Config {
10 pub repo: String,
11}
12
13pub fn path() -> Result<PathBuf> {
14 confy::get_configuration_file_path(APP_NAME, FILE_STEM)
15 .with_context(|| "unable to find the config file")
16}
17
18pub fn load() -> Result<Config> {
19 confy::load(APP_NAME, FILE_STEM).with_context(|| "unable to load config")
20}
21
22pub fn save(config: Config) -> Result<()> {
23 confy::store(APP_NAME, FILE_STEM, config).with_context(|| "unable to save config")
24}