diff --git a/frork-cli/src/assertions.rs b/frork-cli/src/assertions.rs
index 2cd6989..d6db6a0 100644
--- a/frork-cli/src/assertions.rs
+++ b/frork-cli/src/assertions.rs
@@ -426,3 +426,45 @@ impl AssertionType for LuaAssertion {
Ok(())
}
}
+
+pub struct Brew;
+
+impl FromLuaMulti for Brew {
+ fn from_lua_multi(_args: LuaMultiValue, _lua: &Lua) -> LuaResult<Self> {
+ Ok(Self)
+ }
+}
+
+impl std::fmt::Display for Brew {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ write!(f, "brew")
+ }
+}
+
+impl AssertionType for Brew {
+ fn status(&self) -> Result<Status> {
+ let (_output, exit_code) = Utils::sh("brew", &["--version".to_string()])?;
+ if exit_code == 0 {
+ Ok(Status::Ok)
+ } else {
+ Ok(Status::Missing)
+ }
+ }
+
+ fn install(&self) -> Result<()> {
+ let (_output, exit_code) = Utils::sh(
+ "bash",
+ &[
+ "-c".to_string(),
+ r#"/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)""#.to_string(),
+ ],
+ )?;
+
+ if exit_code != 0 {
+ return Err(eyre!("Failed to install Homebrew"));
+ }
+
+ debug!("installed: {}", self);
+ Ok(())
+ }
+}
diff --git a/frork-cli/src/main.rs b/frork-cli/src/main.rs
index cc2c7c6..5428a8f 100644
--- a/frork-cli/src/main.rs
+++ b/frork-cli/src/main.rs
@@ -3,7 +3,7 @@ mod errors;
mod utils;
use assertions::{
- AssertionType, AssertionTypeFactory, Debug, Directory, Git, LuaAssertion, LuaAssertionType,
+ AssertionType, AssertionTypeFactory, Brew, Debug, Directory, Git, LuaAssertion, LuaAssertionType,
Status, Symlink, TypedFactory,
};
use clap::{Parser, Subcommand};
@@ -69,6 +69,7 @@ impl Registry {
// Return factory for built-in types
match assertion_type {
+ "brew" => Ok(Box::new(TypedFactory::<Brew>::new())),
"debug" => Ok(Box::new(TypedFactory::<Debug>::new())),
"directory" => Ok(Box::new(TypedFactory::<Directory>::new())),
"git" => Ok(Box::new(TypedFactory::<Git>::new())),