1use once_cell::sync::Lazy;
6
7const BYTECODE_VERSION_ENV_VAR: &str = "MOVE_BYTECODE_VERSION";
10
11pub fn get_bytecode_version_from_env() -> Option<u32> {
14 std::env::var(BYTECODE_VERSION_ENV_VAR)
15 .ok()
16 .and_then(|s| s.parse::<u32>().ok())
17}
18
19pub fn read_env_var(v: &str) -> String {
20 std::env::var(v).unwrap_or_else(|_| String::new())
21}
22
23pub fn read_bool_env_var(v: &str) -> bool {
24 let val = read_env_var(v).to_lowercase();
25 val.parse::<bool>() == Ok(true) || val.parse::<usize>() == Ok(1)
26}
27
28pub static MOVE_HOME: Lazy<String> = Lazy::new(|| {
29 std::env::var("MOVE_HOME").unwrap_or_else(|_| {
30 format!(
31 "{}/.move",
32 dirs_next::home_dir()
33 .expect("user's home directory not found")
34 .to_str()
35 .unwrap()
36 )
37 })
38});