Skip to content

Commit a3905c0

Browse files
committed
Added torchbear.os
Using `torchbear.os` will return the os that torchbear is running on. If the system is not provided (eg if torchbear is ran on *bsd while there is no check for it) or is not available (eg running on a platform that dont have a valid os in `target_os`), it will return `unknown`.
1 parent 79e09d3 commit a3905c0

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

src/lib.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,18 @@ impl AppState {
9494
tb_table.set("settings", rlua_serde::to_value(&lua, &self.settings).map_err(LuaError::external)?)?;
9595
tb_table.set("init_filename", self.init_path.to_str())?;
9696
tb_table.set("version", env!("CARGO_PKG_VERSION"))?;
97+
let os = if cfg!(target_os = "windows") {
98+
"windows"
99+
} else if cfg!(target_os = "linux") {
100+
"linux"
101+
} else if cfg!(target_os = "macos") {
102+
"macos"
103+
} else if cfg!(target_os = "android") {
104+
"android"
105+
} else {
106+
"unknown"
107+
};
108+
tb_table.set("os", os)?;
97109
lua.globals().set("torchbear", tb_table)?;
98110
}
99111

0 commit comments

Comments
 (0)