Skip to content

Commit 6e74be2

Browse files
authored
Invoke chooser selections separately (#3311)
1 parent 0c08733 commit 6e74be2

2 files changed

Lines changed: 27 additions & 5 deletions

File tree

src/subcommand.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -297,12 +297,16 @@ impl Subcommand {
297297

298298
let stdout = String::from_utf8_lossy(&output.stdout);
299299

300-
let recipes = stdout
301-
.split_whitespace()
302-
.map(str::to_owned)
303-
.collect::<Vec<String>>();
300+
for line in stdout.lines() {
301+
let arguments = line
302+
.split_whitespace()
303+
.map(str::to_owned)
304+
.collect::<Vec<String>>();
304305

305-
justfile.run(config, search, &recipes, overrides)
306+
justfile.run(config, search, &arguments, overrides)?;
307+
}
308+
309+
Ok(())
306310
}
307311

308312
fn completions(shell: Shell) {

tests/choose.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,24 @@ fn cancelled_by_user() {
245245
assert!(output.status.success());
246246
}
247247

248+
#[test]
249+
fn chooser_selections_are_processed_separately() {
250+
Test::new()
251+
.args(["--choose", "--chooser", "cat"])
252+
.write("sub.just", "bar:\n @echo bar\n")
253+
.justfile(
254+
"
255+
mod sub
256+
257+
foo *args:
258+
@echo foo {{args}}
259+
",
260+
)
261+
.stdin("foo\nsub bar\n")
262+
.stdout("foo\nbar\n")
263+
.success();
264+
}
265+
248266
#[test]
249267
fn filter_by_group() {
250268
Test::new()

0 commit comments

Comments
 (0)