Skip to content

Commit

Permalink
fix(actions): warn on unknown injects
Browse files Browse the repository at this point in the history
Resolves #20
  • Loading branch information
norskeld committed Mar 11, 2024
1 parent 07795c8 commit 0ebd002
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/actions/actions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,11 +197,20 @@ impl Echo {
let mut message = message.unindent();

if let Some(injects) = &self.injects {
let mut should_print_nl = false;

for inject in injects {
if let Some(value) = state.get(inject) {
message = message.replace(&format!("{{{inject}}}"), value.to_string().as_str());
} else {
println!("{}", format!("? Unknown injection: {inject}").yellow());
should_print_nl = true;
}
}

if should_print_nl {
println!();
}
}

Ok(println!("{message}"))
Expand All @@ -217,11 +226,20 @@ impl Run {
let spinner = Spinner::new();

if let Some(injects) = &self.injects {
let mut should_print_nl = false;

for inject in injects {
if let Some(value) = state.get(inject) {
command = command.replace(&format!("{{{inject}}}"), value.to_string().as_str());
} else {
println!("{}", format!("? Unknown injection: {inject}").yellow());
should_print_nl = true;
}
}

if should_print_nl {
println!();
}
}

let name = self
Expand Down

0 comments on commit 0ebd002

Please sign in to comment.