Skip to content

Commit

Permalink
move debug processing logic to its own function
Browse files Browse the repository at this point in the history
  • Loading branch information
flawiddsouza committed Nov 12, 2024
1 parent 58829ff commit 7a6157d
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,19 @@ fn should_run_task(
}
}

fn process_debug(
debug: &Debug,
register_map: &IndexMap<String, Register>,
vars_map: &IndexMap<String, Value>,
) {
println!("{}", "Debug:".blue());
for (key, msg) in debug.0.iter() {
println!("{}", format!("{}:", key).blue());
let debug_msg = replace_placeholders(msg, register_map, vars_map);
println!("{}", format!("{}", debug_msg).blue());
}
}

fn main() -> Result<(), Box<dyn std::error::Error>> {
let matches = ClapCommand::new("deploy-helper")
.version("1.0.3")
Expand Down Expand Up @@ -583,12 +596,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
}

if let Some(debug) = &task.debug {
println!("{}", "Debug:".blue());
for (key, msg) in debug.0.iter() {
println!("{}", format!("{}:", key).blue());
let debug_msg = replace_placeholders(msg, &register_map, &local_vars_map);
println!("{}", format!("{}", debug_msg).blue());
}
process_debug(debug, &register_map, &local_vars_map);
}

if let Some(shell_command) = &task.shell {
Expand Down

0 comments on commit 7a6157d

Please sign in to comment.