use crate::commands::constants::*;
use crate::TmuxCommand;
use std::borrow::Cow;
pub type UnlinkW<'a> = UnlinkWindow<'a>;
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Default)]
pub struct UnlinkWindow<'a> {
#[cfg(feature = "tmux_1_0")]
pub detach_other: bool,
#[cfg(feature = "tmux_0_8")]
pub target_window: Option<Cow<'a, str>>,
}
impl<'a> UnlinkWindow<'a> {
pub fn new() -> Self {
Default::default()
}
#[cfg(feature = "tmux_1_0")]
pub fn detach_other(mut self) -> Self {
self.detach_other = 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(UNLINK_WINDOW);
#[cfg(feature = "tmux_1_0")]
if self.detach_other {
cmd.push_flag(K_LOWERCASE_KEY);
}
#[cfg(feature = "tmux_0_8")]
if let Some(target_window) = self.target_window {
cmd.push_option(T_LOWERCASE_KEY, target_window);
}
cmd
}
}