Skip to content

Commit b6410ac

Browse files
committed
Refactor Command into mode-based API
- Introduce ExecutionMode with Silent and Live - Add Command<Mode> generic and mode types Capture and InheritStreams - Implement build and call paths for Capture and InheritStreams - Update Docker and HPC executor usage to new API - Add tests for new modes and IO behavior
1 parent 4b713e4 commit b6410ac

File tree

3 files changed

+267
-102
lines changed

3 files changed

+267
-102
lines changed

src/executor/docker.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,21 +36,21 @@ impl Executor {
3636
fs::create_dir_all(&d)?;
3737
}
3838

39-
let mut command = util::Command::new("docker");
40-
41-
command
39+
let command = util::Command::new("docker")
4240
.arg("run")
4341
.args(options.split(' '))
4442
.arg(&spec.image.0)
4543
.args(spec.args.clone())
4644
.message(format!(
4745
"Executing {} with arguments: {:?}",
4846
self.app, spec.args
49-
));
47+
))
48+
.live();
5049

5150
println!("Running {command}");
5251

53-
let result = command.live().call();
52+
//let result = command.live().call();
53+
let result = command.call();
5454

5555
// let command_line = format!(
5656
// "docker run {options} {} {}",

src/executor/hpc_container.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,21 +41,20 @@ impl Executor {
4141
fs::create_dir_all(&d)?;
4242
}
4343

44-
let mut command = util::Command::new(engine.0);
45-
46-
command
44+
let command = util::Command::new(engine.0)
4745
.arg("run")
4846
.args(options.split(' '))
4947
.arg(image_path.to_string_lossy())
5048
.args(spec.args.clone())
5149
.message(format!(
5250
"Executing {} with arguments: {:?}",
5351
self.app, spec.args
54-
));
52+
))
53+
.live();
5554

5655
println!("Running {command}");
5756

58-
let result = command.live().call();
57+
let result = command.call();
5958

6059
// println!("{}", result.stdout.bright_black());
6160
// eprintln!("{}", result.stderr.bright_red());

0 commit comments

Comments
 (0)