Expose shell via builder

This commit is contained in:
Félix Saparelli 2021-04-11 02:28:29 +12:00
parent 1280a15ca2
commit 92060e5655
No known key found for this signature in database
GPG key ID: B948C4BAE44FC474
3 changed files with 18 additions and 0 deletions

View file

@ -15,6 +15,8 @@
use std::path::PathBuf;
use crate::process::Shell;
/// Arguments to the watcher
#[derive(Builder, Clone, Debug)]
#[builder(setter(into, strip_option))]
@ -46,6 +48,9 @@ pub struct Config {
/// Run the commands right after starting.
#[builder(default = "true")]
pub run_initially: bool,
/// Specify the shell to use.
#[builder(default)]
pub shell: Shell,
/// Do not wrap the commands in a shell.
#[builder(default)]
pub no_shell: bool,

View file

@ -34,6 +34,7 @@ pub mod run;
mod signal;
mod watcher;
pub use process::Shell;
pub use run::{run, watch, Handler};
#[deprecated(since = "1.15.0", note = "Config has moved to config::Config")]

View file

@ -19,6 +19,18 @@ pub enum Shell {
Powershell,
}
impl Default for Shell {
#[cfg(windows)]
fn default() -> Self {
Self::Powershell
}
#[cfg(not(windows))]
fn default() -> Self {
Self::Unix("sh".into())
}
}
pub fn spawn(
cmd: &[String],
updated_paths: &[PathOp],