1
2
3
4
5
6
7
8
9
10
11
12
use anyhow::Context;
use std::path::PathBuf;

pub fn berg_data_dir() -> anyhow::Result<PathBuf> {
    dirs::data_dir()
        .context("Couldn't find data directory for saving the token.")
        .map(|data_dir| data_dir.join(".berg-cli"))
}

pub fn token_path() -> anyhow::Result<PathBuf> {
    berg_data_dir().map(|token_dir| token_dir.join("TOKEN"))
}