Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get Config from ExecutionContext instead of passing separately #2481

Merged
merged 1 commit into from
Nov 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/recipe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,17 +149,15 @@ impl<'src, D> Recipe<'src, D> {
positional: &[String],
is_dependency: bool,
) -> RunResult<'src, ()> {
let config = &context.config;

let color = config.color.stderr().banner();
let color = context.config.color.stderr().banner();
let prefix = color.prefix();
let suffix = color.suffix();

if config.verbosity.loquacious() {
if context.config.verbosity.loquacious() {
eprintln!("{prefix}===> Running recipe `{}`...{suffix}", self.name);
}

if config.explain {
if context.config.explain {
if let Some(doc) = self.doc() {
eprintln!("{prefix}#### {doc}{suffix}");
}
Expand All @@ -168,9 +166,9 @@ impl<'src, D> Recipe<'src, D> {
let evaluator = Evaluator::new(context, is_dependency, scope);

if self.is_script() {
self.run_script(context, scope, positional, config, evaluator)
self.run_script(context, scope, positional, evaluator)
} else {
self.run_linewise(context, scope, positional, config, evaluator)
self.run_linewise(context, scope, positional, evaluator)
}
}

Expand All @@ -179,9 +177,10 @@ impl<'src, D> Recipe<'src, D> {
context: &ExecutionContext<'src, 'run>,
scope: &Scope<'src, 'run>,
positional: &[String],
config: &Config,
mut evaluator: Evaluator<'src, 'run>,
) -> RunResult<'src, ()> {
let config = &context.config;

let mut lines = self.body.iter().peekable();
let mut line_number = self.line_number() + 1;
loop {
Expand Down Expand Up @@ -316,9 +315,10 @@ impl<'src, D> Recipe<'src, D> {
context: &ExecutionContext<'src, 'run>,
scope: &Scope<'src, 'run>,
positional: &[String],
config: &Config,
mut evaluator: Evaluator<'src, 'run>,
) -> RunResult<'src, ()> {
let config = &context.config;

let mut evaluated_lines = Vec::new();
for line in &self.body {
evaluated_lines.push(evaluator.evaluate_line(line, false)?);
Expand Down