Skip to content

Commit

Permalink
Merge branch 'dev' into stable
Browse files Browse the repository at this point in the history
  • Loading branch information
ali77gh committed Nov 23, 2024
2 parents 181bc85 + a0e0f7d commit ed32cd7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
5 changes: 5 additions & 0 deletions cli/src/capabilities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ impl Capabilities for CLICapabilities {
}

fn execute(&self, command: &str) -> bool {
self.message(Message::bake_state(format!(
"running command => '{}'\n",
command
)));

let result = Command::new(SHELL)
.arg(SWITCH)
.arg(command)
Expand Down
11 changes: 11 additions & 0 deletions core/src/viewmodel/dependency_viewmodel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,17 @@ impl DependencyViewModel {
return Ok(());
}

// auto yes if can't get user input
if let Some(false) = self.capabilities.ask_user_yes_no(
format!(
"'{}' is not installed, do you want to install it",
self.name()
)
.as_str(),
) {
return Err(format!("cancel installation {}", self.name()));
}

// *THIS IS RECURSIVE*
// install dependencies of dependency first
bake_view_model.install_dependencies(self.dependencies())?;
Expand Down
9 changes: 1 addition & 8 deletions core/src/viewmodel/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ impl BakeViewModel {
self.dependencies.values().collect()
}

/// Same as [install_dependencies] but in loop
/// Same as [install_dependency] but in loop
/// It will stop iteration on error
pub fn install_dependencies(&self, names: &[String]) -> Result<(), String> {
for name in names {
Expand All @@ -97,13 +97,6 @@ impl BakeViewModel {
/// this installs dependencies and will skip if it's already installed
pub fn install_dependency(&self, name: &str) -> Result<(), String> {
if let Some(dependency) = self.get_dependency(name) {
// auto yes if can't get user input
if let Some(false) = self.caps.ask_user_yes_no(
format!("'{}' is not installed, do you want to install it", name).as_str(),
) {
return Err(format!("cancel installation {}", name));
}

dependency.try_install(self)
} else {
Err(format!("dependency {} not found", name))
Expand Down

0 comments on commit ed32cd7

Please sign in to comment.