use crate::commands::constants::*;
use crate::TmuxCommand;
use std::borrow::Cow;
pub type KillW<'a> = KillWindow<'a>;
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Default)]
pub struct KillWindow<'a> {
#[cfg(feature = "tmux_1_7")]
pub parent_sighup: bool,
#[cfg(feature = "tmux_0_8")]
pub target_window: Option<Cow<'a, str>>,
}
impl<'a> KillWindow<'a> {
pub fn new() -> Self {
Default::default()
}
#[cfg(feature = "tmux_1_7")]
pub fn parent_sighup(mut self) -> Self {
self.parent_sighup = true;
self
}
#[cfg(feature = "tmux_0_8")]
pub fn target_window<S: Into<Cow<'a, str>>>(mut self, target_window: S) -> Self {
self.target_window = Some(target_window.into());
self
}
pub fn build(self) -> TmuxCommand<'a> {
let mut cmd = TmuxCommand::new();
cmd.name(KILL_WINDOW);
#[cfg(feature = "tmux_1_7")]
if self.parent_sighup {
cmd.push_flag(A_LOWERCASE_KEY);
}
#[cfg(feature = "tmux_0_8")]
if let Some(target_window) = self.target_window {
cmd.push_option(T_LOWERCASE_KEY, target_window);
}
cmd
}
}