use std::path::Path;
use std::process::Command;
pub fn command(dir: &Path) -> Command {
let mut command =
Command::new(std::env::var_os("STANDARD_BIN").unwrap_or_else(|| "standard".into()));
command.arg("plugin").arg("install").arg(dir);
command
}
pub fn exec(dir: &Path) -> String {
let mut command = command(dir);
println!("running: standard plugin install {}", dir.display());
#[cfg(unix)]
{
use std::os::unix::process::CommandExt as _;
let error = command.exec();
format!("could not run `standard` ({error}); install Standard Code or set STANDARD_BIN")
}
#[cfg(not(unix))]
{
match command.status() {
Ok(status) if status.success() => String::new(),
Ok(status) => format!("standard plugin install exited with {status}"),
Err(error) => format!("could not run `standard` ({error})"),
}
}
}