Skip to content

Commit c8e7bf7

Browse files
committed
Add a --run-args argument
1 parent bf405e3 commit c8e7bf7

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/args.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ where
220220
.canonicalize()
221221
.map_err(|err| format!("Failed to canonicalize executable path: {}", err))?;
222222
let mut run_command = None;
223+
let mut run_args = None;
223224

224225
loop {
225226
match arg_iter.next().as_ref().map(|s| s.as_str()) {
@@ -230,6 +231,13 @@ where
230231
}
231232
break;
232233
}
234+
Some("--args") => {
235+
let old = mem::replace(&mut run_args, Some(arg_iter.collect()));
236+
if !old.is_none() {
237+
Err("multiple `--args` arguments")?;
238+
}
239+
break;
240+
}
233241
Some("--help") | Some("-h") => {
234242
return Ok(Command::RunnerHelp);
235243
}
@@ -244,13 +252,15 @@ where
244252
Ok(Command::Runner(RunnerArgs {
245253
executable,
246254
run_command,
255+
run_args: run_args,
247256
}))
248257
}
249258

250259
#[derive(Debug, Clone)]
251260
pub struct RunnerArgs {
252261
pub executable: PathBuf,
253262
pub run_command: Option<Vec<String>>,
263+
pub run_args: Option<Vec<String>>,
254264
}
255265

256266
#[derive(Debug, Clone)]

src/subcommand/runner.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ pub(crate) fn runner(args: RunnerArgs) -> Result<(), ErrorString> {
2020
for arg in &run_cmd[1..] {
2121
command.arg(arg.replace("{bootimage}", &format!("{}", bootimage_bin.display())));
2222
}
23+
if let Some(run_args) = args.run_args {
24+
command.args(run_args);
25+
}
2326
let output = command
2427
.output()
2528
.map_err(|e| format!("Failed to execute `{:?}`: {}", command, e))?;

0 commit comments

Comments
 (0)