mirror of
https://github.com/watchexec/watchexec.git
synced 2024-11-13 07:41:11 +01:00
Add command and shell options to action
This commit is contained in:
parent
613fe24c64
commit
227c2a0e0d
2 changed files with 20 additions and 1 deletions
|
@ -16,6 +16,7 @@ use tokio::{
|
|||
use tracing::{debug, trace};
|
||||
|
||||
use crate::{
|
||||
command::Shell,
|
||||
error::{CriticalError, RuntimeError},
|
||||
event::Event,
|
||||
handler::{rte, Handler},
|
||||
|
@ -26,8 +27,12 @@ use crate::{
|
|||
pub struct WorkingData {
|
||||
pub throttle: Duration,
|
||||
|
||||
/// TODO: notes on how outcome is read immediately after handler returns
|
||||
pub action_handler: Arc<AtomicTake<Box<dyn Handler<Action> + Send>>>,
|
||||
|
||||
pub shell: Shell,
|
||||
|
||||
/// TODO: notes for command construction ref Shell and old src
|
||||
pub command: Vec<String>,
|
||||
}
|
||||
|
||||
impl fmt::Debug for WorkingData {
|
||||
|
@ -44,6 +49,8 @@ impl Default for WorkingData {
|
|||
// set to 50ms here, but will remain 100ms on cli until 2022
|
||||
throttle: Duration::from_millis(50),
|
||||
action_handler: Arc::new(AtomicTake::new(Box::new(()) as _)),
|
||||
shell: Shell::default(),
|
||||
command: Vec::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,6 +53,18 @@ impl RuntimeConfig {
|
|||
self
|
||||
}
|
||||
|
||||
/// Set the shell to use to invoke commands.
|
||||
pub fn command_shell(&mut self, shell: Shell) -> &mut Self {
|
||||
self.action.shell = shell;
|
||||
self
|
||||
}
|
||||
|
||||
/// Set the command to run on action.
|
||||
pub fn command<'cmd>(&mut self, command: impl IntoIterator<Item = &'cmd str>) -> &mut Self {
|
||||
self.action.command = command.into_iter().map(|c| c.to_owned()).collect();
|
||||
self
|
||||
}
|
||||
|
||||
/// Set the action handler.
|
||||
///
|
||||
/// TODO: notes on how outcome is read immediately after handler returns
|
||||
|
|
Loading…
Reference in a new issue