glossa-cli 0.0.0

A command-line (binary) tool that generates Rust source code or bincode files containing localized text by calling the glossa-codegen API.
Documentation
use std::path::{Path, PathBuf};

use glossa::sys::new_once_lock;

pub fn config_dir() -> &'static Path {
  new_once_lock!(V: PathBuf);

  V.get_or_init(|| {
    let proj_dir = || match directories::ProjectDirs::from("me", "tmoe", "glossa")
      .map(|d| d.config_local_dir().into())
    {
      Some(v) => v,
      _ => std::env::temp_dir().join("me.tmoe.glossa"),
    };

    match crate::envs::static_glossa_cfg_dir() {
      Some(v) => v.into(),
      _ => proj_dir(),
    }
  })
}

pub fn bincode_dir() -> Option<&'static Path> {
  new_once_lock!(P: Option<PathBuf>);

  P.get_or_init(|| {
    let dir = config_dir();
    dir
      .exists()
      .then(|| dir.join("bincode"))
      .filter(|x| x.exists())
  })
  .as_deref()
}