1 pub mod constants;
2
3 use anyhow::{anyhow, Result};
4 use log::debug;
5
6 pub async fn get_token() -> Result<String> {
7 if let Some(mut path) = dirs::home_dir() {
8 path.push(".smb/token");
9 std::fs::read_to_string(path).map_err(|e| {
10 debug!("Error while reading token: {}", &e);
11 anyhow!("Error while reading token. Are you logged in?")
12 })
13 } else {
14 Err(anyhow!("Failed to get home directory."))
15 }
16 }