Initial commit
This commit is contained in:
commit
6e1613f73f
48 files changed
+13682
No files matched your search
+41
@@ -0,0 +1,41 @@
|
||||
use clap::Parser;
|
||||
use clap::ValueEnum;
|
||||
use directories::BaseDirs;
|
||||
use std::path::PathBuf;
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
#[command(version, about, long_about = None)]
|
||||
pub struct Args {
|
||||
#[arg(value_enum)]
|
||||
pub game: Game,
|
||||
|
||||
pub build_path: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, ValueEnum)]
|
||||
pub enum Game {
|
||||
#[value(name = "poe1")]
|
||||
Poe1,
|
||||
#[value(name = "poe2")]
|
||||
Poe2,
|
||||
}
|
||||
|
||||
static GAME_CONFIG: std::sync::OnceLock<Game> = std::sync::OnceLock::new();
|
||||
|
||||
impl Game {
|
||||
pub fn init(game: Game) {
|
||||
GAME_CONFIG.set(game).expect("Game should be uninitialized");
|
||||
}
|
||||
|
||||
pub fn current() -> &'static Game {
|
||||
GAME_CONFIG.get().expect("Game should be initialized")
|
||||
}
|
||||
|
||||
pub fn script_dir() -> PathBuf {
|
||||
let directory_name = match Self::current() {
|
||||
Game::Poe1 => "PathOfBuilding1",
|
||||
Game::Poe2 => "PathOfBuilding2",
|
||||
};
|
||||
BaseDirs::new().unwrap().data_dir().join(directory_name)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user