standard_plugin_cli/
install.rs1use std::path::Path;
7use std::process::Command;
8
9pub fn command(dir: &Path) -> Command {
11 let mut command =
12 Command::new(std::env::var_os("STANDARD_BIN").unwrap_or_else(|| "standard".into()));
13 command.arg("plugin").arg("install").arg(dir);
14 command
15}
16
17pub fn exec(dir: &Path) -> String {
20 let mut command = command(dir);
21 println!("running: standard plugin install {}", dir.display());
22 #[cfg(unix)]
23 {
24 use std::os::unix::process::CommandExt as _;
25 let error = command.exec();
26 format!("could not run `standard` ({error}); install Standard Code or set STANDARD_BIN")
27 }
28 #[cfg(not(unix))]
29 {
30 match command.status() {
31 Ok(status) if status.success() => String::new(),
32 Ok(status) => format!("standard plugin install exited with {status}"),
33 Err(error) => format!("could not run `standard` ({error})"),
34 }
35 }
36}