Skip to main content

doido_generators/commands/
runner.rs

1//! `doido runner <args>` — run application code. Rust can't evaluate snippets,
2//! so this runs the app's own binary (`cargo run -- <args>`), letting the app
3//! dispatch on the arguments.
4
5use std::process::Command;
6
7/// The program + args used to run application code.
8pub fn runner_command(args: &[&str]) -> (String, Vec<String>) {
9    let mut cargo_args = vec!["run".to_string(), "--quiet".to_string(), "--".to_string()];
10    cargo_args.extend(args.iter().map(|s| s.to_string()));
11    ("cargo".to_string(), cargo_args)
12}
13
14pub fn run(args: &[&str]) {
15    let (program, cargo_args) = runner_command(args);
16    let _ = Command::new(program).args(cargo_args).status();
17}