Skip to content

Commit 8636906

Browse files
authored
Move choose and run into match statement (#3120)
1 parent c907cfa commit 8636906

1 file changed

Lines changed: 30 additions & 29 deletions

File tree

src/justfile.rs

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,33 @@ impl<'src> Justfile<'src> {
128128
let scope = scopes.get(&self.module_path).unwrap().1;
129129

130130
match &config.subcommand {
131+
Subcommand::Choose { .. } | Subcommand::Run { .. } => {
132+
let arguments = arguments.iter().map(String::as_str).collect::<Vec<&str>>();
133+
134+
let invocations = InvocationParser::parse_invocations(self, &arguments)?;
135+
136+
if config.one && invocations.len() > 1 {
137+
return Err(Error::ExcessInvocations {
138+
invocations: invocations.len(),
139+
});
140+
}
141+
142+
let ran = Ran::default();
143+
for invocation in invocations {
144+
Self::run_recipe(
145+
&invocation.arguments,
146+
config,
147+
&dotenv,
148+
false,
149+
&ran,
150+
invocation.recipe,
151+
&scopes,
152+
search,
153+
)?;
154+
}
155+
156+
Ok(())
157+
}
131158
Subcommand::Command {
132159
binary, arguments, ..
133160
} => {
@@ -167,7 +194,7 @@ impl<'src> Justfile<'src> {
167194
return Err(Error::Interrupted { signal });
168195
}
169196

170-
return Ok(());
197+
Ok(())
171198
}
172199
Subcommand::Evaluate { variable, .. } => {
173200
if let Some(variable) = variable {
@@ -194,36 +221,10 @@ impl<'src> Justfile<'src> {
194221
}
195222
}
196223

197-
return Ok(());
224+
Ok(())
198225
}
199-
_ => {}
226+
_ => unreachable!(),
200227
}
201-
202-
let arguments = arguments.iter().map(String::as_str).collect::<Vec<&str>>();
203-
204-
let invocations = InvocationParser::parse_invocations(self, &arguments)?;
205-
206-
if config.one && invocations.len() > 1 {
207-
return Err(Error::ExcessInvocations {
208-
invocations: invocations.len(),
209-
});
210-
}
211-
212-
let ran = Ran::default();
213-
for invocation in invocations {
214-
Self::run_recipe(
215-
&invocation.arguments,
216-
config,
217-
&dotenv,
218-
false,
219-
&ran,
220-
invocation.recipe,
221-
&scopes,
222-
search,
223-
)?;
224-
}
225-
226-
Ok(())
227228
}
228229

229230
pub(crate) fn check_unstable(&self, config: &Config) -> RunResult<'src> {

0 commit comments

Comments
 (0)