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