Skip to main content

lux_cli/
install_lua.rs

1use lux_lib::{config::Config, lua_installation::LuaInstallation, lua_version::LuaVersion};
2
3use miette::{miette, Result};
4
5pub async fn install_lua(config: Config) -> Result<()> {
6    let version_stringified = &LuaVersion::from(&config)?;
7
8    // TODO: Detect when path already exists by checking `Lua::path()` and prompt the user
9    // whether they'd like to forcefully reinstall.
10    let lua = LuaInstallation::install(version_stringified, &config).await?;
11    let lua_root = lua
12        .includes()
13        .first()
14        .and_then(|dir| dir.parent())
15        .ok_or_else(|| miette!("error getting lua include parent directory"))?;
16
17    tracing::info!(
18        "Installed Lua ({}) to {}",
19        version_stringified,
20        lua_root.display(),
21    );
22
23    Ok(())
24}